Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jun 2001
    Location
    Bethlehem, Pennsylvania, USA
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    open form to selected record (Access 2k)

    I have a database that has a form, which has a listing of items, and another form, which has the item details. Both of these forms are generetated-using queries. What I would like to do is when I select a item in the listing form (using the record selector), that the detail form would open to the corresponding detail record. I am using Access 2k.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: open form to selected record (Access 2k)

    Use the OnCurrent event of the first form and open the second form something like this:

    DoCmd.OpenForm "frmDetails", , , "[KeyID]=" & Me!txtKeyID

    This assumes that
    1) the form you're opening is named "frmDetails",
    2) there is a key field in the second form's recordset called "KeyID",
    3) there is a textbox on your first form called txtKeyID that is bound to an underlying field that contains the value you want to pass as a key to the second form, and
    4) that "KeyID" is a numeric key. If it were a string, you would have to make the WhereCondition "[KeyID]= ' " & Me!txtKeyID & " ' "

    Does that answer your question?
    Charlotte

  3. #3
    3 Star Lounger Omega3's Avatar
    Join Date
    Jan 2004
    Location
    Los Angeles, California, USA
    Posts
    343
    Thanks
    2
    Thanked 1 Time in 1 Post
    I am trying to do what the original post is doing. Charlotte’s solution works. I thought of using the record selector instead of a command button to select the record that the user wants to see the details of by opening a second form.

    My problem is that when the first (continuous) form first opens the form’s on current event fires off and displays the details of the first record in the continuous form by using a second form.

    Is there a way to suppress or prevent that when the form first opens and only do it when the user clicks on the record selector?
    You know it's time to diet when you push away from the table and the table moves.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You want to use the On Click event of the form (not of the Detail section or anything else on the form). This event occurs when the user clicks on the record selector.

  5. #5
    3 Star Lounger Omega3's Avatar
    Join Date
    Jan 2004
    Location
    Los Angeles, California, USA
    Posts
    343
    Thanks
    2
    Thanked 1 Time in 1 Post
    [quote name='HansV' post='779185' date='10-Jun-2009 12:08']You want to use the On Click event of the form (not of the Detail section or anything else on the form). This event occurs when the user clicks on the record selector.[/quote]

    Ah, the record selector fires off the OnClick event of the form!!! And I was using the OnCurrent event and it seemed to work except for the problem I described above.

    Once again, thank you Hans!!!!
    You know it's time to diet when you push away from the table and the table moves.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •