Module/VBA Question (1 Viewer)

M

mames

Guest
Hello!
I am creating a dbase for work and I have a task that requires more skills than I have!

I need to run a query into a form, use checkboxes to select the addresses I need and then merge them into a report.

I have the query, it selects entries by county (prompting the user to enter the county of choice). I also created the report that uses this query but it merges ALL the entries for the county selected. We need to be able to choose which ones we need to merge instead of all 100+ entries. I've created some macros that help with the switchboard usage of what I've done so far but modules/VBA is waaaay beyond me at this point and I think I may need it. :confused:

This feels like it is SO far beyond my abilities, I hope there are some Guru's out there! :eek:

Thanks bunches,
Mames
 

Roly Reefer

Registered User.
Local time
Today, 14:20
Joined
Jan 28, 2005
Messages
37
Module / VBA Question

Hi Mames,

Have you tried a parameters box in the query, or does this spoil other parts of the database?

I can't help you with VBA coz I have only jsut started and am rubbish!!!

Good luck,


Roly
 

vabki

Registered User.
Local time
Today, 09:20
Joined
Jan 26, 2005
Messages
11
Hello,

You'll need more than a single form to solve your problem.

While your form, query and the underlying table are a good place to start, there are a few missing steps. Also, my users seem to prefer forms to switchboard entries, so I'll respond in that fashion.

1. I assume you've modified the table, query and form for the checkbox value (t/f, selected or not).

2. Open the query and save it with a new name ("oldname_selected" or something meaningful to you). Then add the checkbox field to the query (double-click the field name or use the drop-down picker in the "Field" row), set its "Show" (or not) and key "True" (or whatever "selected" value your set up) in the Criteria row for that column. Save the query again. Test it (assuming you have some entries that are selected while others are not).

3. Build a "main" form. Put a control button on it. This should launch a wizard, where you can direct what a "click" of the button will do. Tell it to "Open form" and point it at your original form. A click by the user will show tham all entries in the table, along with the value in the checkbox ("selected" or not). Save this "main" form.

4. Go back to the queries tab and create a new query using "design view". Select you table. In the first row and column, use the picker to choose the checkbox field. In the commands area, find the "Query Type" drop down and choose "Update Query". When the row headings change, select the "Update to" entry and enter whatever value means "selected". Save this queery as "list_MarkAll". Test the query. (This query allows the user to quickly mark every entry in the table for inclusion in the task at hand.) Now save the query again as "list_UnmarkAll". Change the "Update to " value to your "not selected" value. Test it again, and save it.

5. Go back to your main form and put another button on it, using the wizard to point it to "Run query" "list_MarkAll"; then, do this again pointing to "list_UnmarkAll". Give the buttons appropriate captions.

6. Now you need a query to identify the entries that the user has selected for a particular task. Go to the query tab, create a new one and tell it to select entries with a checkbox value of "selected". Test it and save it.

7. Back to your main form again, to add another button. This time tell it, again, to open a form and point it at any one of your forms - this is only a temporary step, just to get the outline of the code you'll need in the application's code repository. Once the button is on the form, make sure it has focus on the form, and click the button for "code" (in the same general area where you found the drop down picker the the query type).

8. The code window should open to the code just produced by the wizard. Study what it did based on your choices. Find the Docmd.OpenForm line. Highlight the code from the period after Docmd until the end of the line, and then hit the period key on the keyboard; the selected text should be replaced with a "." and you should get a "context-sensitive" list of subcommands that are available (associated) with the Docmd "object". Go down the list until you find transfertext. There are more parameters to follow, but you don't know what they mean yet, so hit the "enter" key on the keyboard. Go back and highlight "transfertext", and then hit the "F1" key. Help should launch and wshow you all the options in the transfertext "method". Once you understand all your options here, go back to the code window, unselect "transfertext" (or go to the end of the line), hit the space bar and the "context-sensitive help" will reappear. Save your project again.

9. Go back to the main form, clean up any button captions you don't like, and rearrange the buttons into a logical order on the form. A quick way to get to the "properties" for an object on the form is to "right-click" on it and choose properties at the bottom of the window. If you want to see the form's properties, choose the square near the top-left corner of the form (just below the title bar). The form is where you determine the order of "tabbing" from button to button (object to object) on the form.

This can get a lot more complicated, if you want it to. In one of my applications, I launch MS Word and "feed" it the commands to merge and print data so the (inexperienced) user didn't have to learn something new, and then mark the entries for the "batches" that have been processed (in case there's a power loss and we don't want to restart from the beginning) so they can't get processed and mailed twice.

Good luck!
 

Users who are viewing this thread

Top Bottom