Find Record in sub form from Look up on parent form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cwby1966
    New Member
    • Feb 2007
    • 49

    Find Record in sub form from Look up on parent form

    I have a parent form that that has a combo field that i want to have it look up and find a record in the sub form.
    Code:
    Private Sub List20_AfterUpdate()
        ' Find the record that matches the control.
        Dim rs As Object
    
        Set rs = qry_drawingdata.Clone
        rs.FindFirst "[drawingnumber] = '" & Me![List20] & "'"
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub
    Can someone help me
    Thanks
  • PianoMan64
    Recognized Expert Contributor
    • Jan 2008
    • 374

    #2
    Originally posted by cwby1966
    I have a parent form that that has a combo field that i want to have it look up and find a record in the sub form.
    Code:
    Private Sub List20_AfterUpdate()
        ' Find the record that matches the control.
        Dim rs As Object
    
        Set rs = qry_drawingdata.Clone
        rs.FindFirst "[drawingnumber] = '" & Me![List20] & "'"
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub
    Can someone help me
    Thanks
    What you need to do is change some of the syntax, and you're in business:

    [code=vb]
    Private Sub List20_OnChange ()
    Dim db As DAO.Database
    Dim rs As DAO.Recordset

    Set db = CurrentDb()
    Set rs = db.OpenRecordse t("SELECT * FROM {TableName} WHERE DrawingNumber = '" & Me.list20.Value & "'", dbOpenSnapshot)

    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    rs.Close
    db.Close
    Set rs = Nothing
    Set db = Nothing
    End Sub
    [/code]

    Comment

    Working...