Reverse Lookup

Posted on 2012-09-06
Last Modified: 2012-09-06
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?
Question by:lauriecking0623
    LVL 61

    Accepted Solution

    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


    Author Closing Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now