macro where statement problem

  • Thread starter Thread starter p-rat
  • Start date Start date
P

p-rat

I have a macro that I use from the Switchboard to open a form. I have
a where statement in the macro to ask the user to type in an ID number
to pull the record into the form. I can't figure out the where
statement. When clicking on the switchboard it pulls in the parameter
text box (I guess that's what it is) with ID?. I type in the ID of the
record I want, but it pulls in the first record every time into this
form. I have the form in Edit mode. I'm sure I'm doing something wrong
in the where statement. Could someone explain to me how this works?
The statement that is. Do I put ID (from table) = ID (from parameter
text box)???

Sorry not very skilled in this Access stuff. Thanks for any help you
may provide.
 
There's another approach you might want to consider. It sounds like your
approach requires the user to memorize record IDs.

You can add a combobox control to the header section of a form. Leave the
combobox "unbound", and use a query to fill it with the various records IDs
from which you wish the user to choose. Better still, in the query, get the
recordID, but get other fields that make it easier for the user to recognize
which record they're after (e.g., if you were asking them to pick a person,
show the person's name).

Base the form on another query, one that returns all the records from the
main table. Now modify the query to only return the record that is selected
in the combobox of the form (a selection criterion).

One more thing -- add something like the following to the AfterUpdate event
of the combobox:

Me.Requery

Here's what happens:

1. open the form -- because there's nothing selected (yet) in the
combobox, the form loads up with ... no record.
2. select the ID/person/whatever from the combobox
3. the AfterUpdate event fires, requerying the form, which re-runs its
query, which FINDS the value in the combobox, and displays the one record
you wanted.

Will this do what you're trying to accomplish?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Back
Top