How to select a record from a list box?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ryno Bower
    New Member
    • Nov 2010
    • 76

    #1

    How to select a record from a list box?

    Hi,

    This is what I have.
    I have 2 forms called (1) "LessonOutcomeA dd" and
    (2) "LessonOutcomes ". (2) is a list box with showing all the Records in (1).
    The identifier in (1) is "ID"
    What I want to do is the following.

    If there is a record that I want to edit I will open form (1). It has a search button that opens form (2) showing all the records. When I double click on a record in (2) then it must go to that specific selected record in (1) and then allow me to edit that record.
    If you can help me on this it would be very appreciated.

    Thank you!
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    The following Code, in the Dbl-Click() Event of the LessonOutcome List Box, should do the trick. Just remember 2 things:
    1. Form LessonOutcomeAd d must be Open.
    2. LessonOutcomeAd d will now be Filtered, and displays only a single Record for editing.

    Code:
    Private Sub LessonOutcomes_DblClick(Cancel As Integer)
    Dim lngID As Long
    Dim frm As Form
    
    'Assumes that [ID] is the Bound Column for LessonOutComes
    lngID = Me![LessonOutcomes]
    
    Set frm = Forms![LessonOutcomeAdd]
    
    With frm
      'Set Focus to the Calling Form (LessonOutcomeAdd)
      frm.SetFocus
    
      'Set the correct Filter for the LessonOutcomeAdd Form & turn it on
      frm.Filter = "[ID] = " & lngID
      frm.FilterOn = True
    End With
    
    'Close the LessonOutcome Form
    DoCmd.Close acForm, "LessonOutcome", acSaveNo       'Criteria Form only
    End Sub

    Comment

    • Ryno Bower
      New Member
      • Nov 2010
      • 76

      #3
      Great!!!!!!!! It's working perfectly.

      Comment

      Working...