Enter value and open form to that record

G

Guest

I know this is possible, but I can't remember how.

I have a form based on a table. On the form is an unbound text box for the
user to enter the ID number of the record he wants to go to. Right now the
user has to enter a number and then click the command button to open the form
to that record. Or, since the command button has the focus after the text
box, the user can hit enter twice (once to go to the command button and the
second time to click the command button) to go to the record. I would like
the user to be able to enter an ID number and hit enter once to go to the new
record. I tried setting the focus to the command button in the after update
event of the text box--that does not work.

I am wracking my brain trying to remember how this is done. I would
appreciate your help!

Thank you,
Judy
 
J

Jeff Boyce

Judy

Not exactly what you described, but ...

Start with a form. Base the record source of the form on the ID value in a
combobox on the form (look ahead!).

Add an unbound combobox. Base the combobox on a query that includes a more
user-friendly way to pick a record (ID numbers are so ... numeric). Also
include the ID number in the query.

In the combobox's AfterUpdate event, requery the form. Now it tries to
reload, looking for the record who's ID is in the combobox.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

Thank you for your response.

I thought about moving to another record this way (I found an Access page
about this subject). But the users are so used to a text box and button,
they asked to keep the form "familiar". I know it is possible to do what I
want to do (I had another form once where I had this working) but I can't
remember how to do it--and it's driving me crazy.
 
D

Dirk Goldgar

Judy Ward said:
I know this is possible, but I can't remember how.

I have a form based on a table. On the form is an unbound text box
for the user to enter the ID number of the record he wants to go to.
Right now the user has to enter a number and then click the command
button to open the form to that record. Or, since the command button
has the focus after the text box, the user can hit enter twice (once
to go to the command button and the second time to click the command
button) to go to the record. I would like the user to be able to
enter an ID number and hit enter once to go to the new record. I
tried setting the focus to the command button in the after update
event of the text box--that does not work.

I am wracking my brain trying to remember how this is done. I would
appreciate your help!

You could easily use the AfterUpdate event of the text box to do
whatever the button's Click event procedure is doing. But then you'd
probably have to dispense with the button entirely, or do nothing in its
Click event, because the simple fact of clicking on the button after
entering something in the text box would cause the text box's
AfterUpdate event to fire.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top