View Full Version : Advanced Form Navigation using Macros


PHu
10-13-2006, 10:23 AM
I could use a hand with something.

I need to find a way to connect questions for data entry in a lengthy survey. There are several sets of questions and each set has its own form.

The tricky part is that the navigation button on each form needs to be able to pick the appropriate set of questions (to continue with the survey) based on two factors chosen at the start of the survey: Language and Region.

For example, if you speak French and are from Quebec, at certain points in the survey you should go to a different form than if you speak English and are from British Columbia. There is a base set of questions that ALL respondents answer and there are many sets of regional questions which come up at various points in the survey (but they are not fixed points. Some regions have their specific questions at different points in the base set than others).

Unfortunately, I can't just copy the base set multiple times to simplify the programming for several reasons.

Any help would be much appreciated. I have a fair bit of experience with basic Access functions but I have nearly no experience with macro use and SQL (if that is what I need). I'm working with Access 2003. Thanks in advance.

grnzbra
10-24-2006, 10:59 AM
You could use hidden fields and in the on open event for each form, check the values for the first factors and then make visible the appropriate questions/fields etc.

I did something similar to this in which the On Open event of a report opened a form and passed in the the name of the calling report. The On Open event of the form used this info to select records from a table telling which fields went with that report and made them visible, located them on the form, set the caption for the field's label and made a note of whether or not the field was a required field (in which case it would display a nastygram if someone failed to fill in the field)

You should be able to do something similar. You might not even need to have a full set of fields for each language/region combination. Determine how many special fields are required by the combination that requires the most fields and then reuse them.

OOps. I just realized that this is in the Macro section, not the VBA section. I don't know how to do make controls visible and set their locations using macros, but if it can be done, I think that it would be the cleanest way to do it.

PHu
10-24-2006, 01:30 PM
Thanks for the response. I'm not any closer to a solution than I was two weeks ago but I haven't tried very hard.

I'll take a closer look at your VBA advice and see if that leads me anywhere.

grnzbra
10-25-2006, 10:45 AM
My task was to create a parameter form to recieve paramters for various reports. The set of reports shared a set of parameters - some reports required the same parameters and some required different parameters. Typically, they required a start date, an end date and an office number. But other reports, which compared two periods, required a second set of dates.

I had a Reports table that listed the reports. I had a parameters table that listed the various possible parameters. Then there was a third table linking these two tables and containing the two key fields, size of the field on the form for that report, location on the form for that report, label caption for that report, was it a required parameter for that report, etc.

This was called from the OnOpen event of the report. The OpenArgs parameter of the OpenForm command was set to Name() so that the name of the report was passed to the form. Each report used the same command to open the form.

In the OnOpen event of the form, a recordset was opened which selected all of the records for that report from the linking table and then looped through the records and set the properties (visible, top, left) for all of the fields corresponding to those that showed in the records.

I think you could very easily so something similar base upon the two original parameters.