[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 400
  • Last Modified:

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.Close
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?
0
lauriecking0623
Asked:
lauriecking0623
1 Solution
 
mbizupCommented:
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

0
 
lauriecking0623Author Commented:
This worked great. Thank you. I can do the reverse of the lookup in my database.
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now