Double-clicking on a particular record to open up that record in a different form

Posted on 2012-08-24
Last Modified: 2012-08-24
I have been racking my brain over and over this code to allow an user to double-click on a particular record on my main dashboard screen to open up another form and go to that particular record that I double-clicked on.

The primary key has been set and I would want it to find that record in the other form based on the primary key.  I can get the double-click to open up the form but it will not go to the particular record.  

So my question is how can I put together code to all me to do that?
Question by:lauriecking0623
    LVL 61

    Assisted Solution

    You would use a WHERE condition in your OpenForm statement:

    DoCmd.OpenForm "YourOtherForm", WhereCondition := "YourIDField = " & Me.ID

    Open in new window


    Author Comment


    When I put in the code into my application and double-click on a record in my datasheet, it gives me a window "Enter Parameter Value".

    I put the code as DoCmd.OpenForm "CASES", WhereCondition :="Case_Number =" & Me.Case_Number.

    My case number is "LL-00001" format with two letters, hyphen and five digits. I am wondering if I have to doing something more with the string.

    Did I put that in correctly?
    LVL 61

    Assisted Solution

    If casenumber is Text, use this syntax instead:

    DoCmd.OpenForm "CASES", WhereCondition :="Case_Number ='" & Me.Case_Number & "'"

    Open in new window

    My previous post assumed it was numeric.

    If you are getting a parameter prompt, you also need to verify that you have a field named "Case_Number" in your CASES form's recorsource table or query.
    LVL 61

    Accepted Solution

    In other words, check that the field exists in the recordsource of form CASES exactly as you have written it.  A common mistake is to use underscores to replace spaces in field names.  If your field name contains a space, you would have to use this syntax with square brackets:

    DoCmd.OpenForm "CASES", WhereCondition :="[Case Number] ='" & Me.Case_Number & "'"

    Open in new window


    Author Closing Comment

    This worked perfectly now. THANK YOU so much!!!!!!!

    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.

    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    737 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

    19 Experts available now in Live!

    Get 1:1 Help Now