Reverse Lookup

I am stuck on this piece of my database.  When I double-click on my datasheet, it will open up the associated form and take the user to the record that they double-clicked on.

So I used this code,

DoCmd.OpenForm "FRM"Requests". WhereCondition:="[REQUEST_ID]=""" & Me.REQUEST_ID & """"

It works great.  What I would like to do is put a button next to the REQUEST_ID on another form like DATA_OBJECTS when the user clicks on the button it will open up the REQUEST_ID form and take the user to that particular record. It won't work.

I get an error when I click on the button stating the following:

Run-time error '2467':
The expression you entered refers to an object that is closed or doesn't exist.

I know it exists. I do not know why my code won't open up the form using this button. It works on my datasheets.

Any suggestions?
Who is Participating?
mbizupConnect With a Mentor Commented:
Since the open form statement refers to a control on the current form, be sure to place that statement before the close statement:

DoCmd.OpenForm "YourFormName". WhereCondition:="[REQUEST_ID]='" & Me.REQUEST_ID & "'"
DoCmd.Close acform, Me.Name

Open in new window

lauriecking0623Author Commented:
This worked great. Thank you. I can do the reverse of the lookup in my database.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.