Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Return/display multiple mainform records after search in subform?

Discussion in 'Information Technology' started by Ricter, Jul 28, 2006.

  1. Ricter

    Expand Collapse

    I've adapted the following code, copied from Allen Browne's reply to this
    thread, "Best way to handle Find in Subform", to my database:

    Private Sub txtFindOrder_AfterUpdate()
    Dim rs As DAO.Recordset
    Dim strWhere As String
    Dim varResult As Variant

    If Not IsNull(Me.txtFindOrder) Then
    If Me.Dirty Then 'Save first
    Me.Dirty = False
    End If
    'Lookup the customer for this order.
    strWhere = "OrderID = " & Me.txtFindOrder
    varResult = DLookup("CustomerID", "Orders", strWhere)
    If IsNull(varResult) Then
    MsgBox "No such order."

    'Find the record in the main form.
    strWhere = "CustomerID = """ & varResult & """"
    Set rs = Me.RecordsetClone
    rs.FindFirst strWhere
    If rs.NoMatch Then
    MsgBox "Customer not found. Is form filtered?"
    Me.Bookmark = rs.Bookmark
    Set rs = Nothing

    'Now find in the subform.
    strWhere = "OrderID = " & Me.txtFindOrder
    With Me.[Customer Orders Subform1].Form
    Set rs = .RecordsetClone
    rs.FindFirst strWhere
    If rs.NoMatch Then
    MsgBox "Not found in subform"
    .Bookmark = rs.Bookmark
    End If
    End With
    End If
    End If
    End If
    Set rs = Nothing
    End Sub

    However, this is only taking me to one record associated with the subform
    field value (the first), even though there are multiple records associated
    with the subform field value.

    How can/should I return all records associated with a search in the subform?
  2. Loading...

Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     

Share This Page