Find a record on a subform

Tiger955

Registered User.
Local time
Today, 10:28
Joined
Sep 13, 2013
Messages
140
Hi!

On a from ("Customers") with tabs I have on the second tab a subform ("Orders") as a single form with a field "Ordernumber". "Customers" and "Orders" are linked through "CustomerID".

On the mainform I have a "searchfield" in which a enter the Ordernumber, I want to find.

I cannot manage it, that After_Update of the "searchfield" the ordernumber is found on the subform and the focus is on that subform.

The focus only shows me the CustomerID on the first tab, but does not jump to the second tab exactly to thes searched ordernumber.


Code:
Private Sub searchfield_AfterUpdate()
Dim rs As Recordset
    Me.CustomerID.SetFocus
        Set rs = Me.Orders.Form.RecordsetClone
        rs.FindFirst "ordernumber = " & Me.searchfield    
    If Not rs.EOF Then Me.Orders.Form.Bookmark = rs.Bookmark
End Sub

Pls help me with that problem.
Michael
 
I assume that searchfield is a control on your main form. I think by assigning the clone recordset to another recordset will mean the bookmark is invalid.

Try

Code:
 Private Sub searchfield_AfterUpdate()

    Me.Orders.Form.RecordsetClone.movefirst
    Me.Orders.Form.RecordsetClone.FindFirst "ordernumber = " & Me.searchfield    
    Me.Orders.Form.Bookmark = Me.Orders.Form.RecordsetClone.Bookmark
    me.orders.setfocus
  
 End Sub
 
Thanks a lot for the fast and correct answer!
 
oooh!

It DID not work!

It was just by chance, that it workes, when you are on the customer and you select an order this customer has done.

but to change to another customer and find that order, this does not work!!
 

Users who are viewing this thread

Back
Top Bottom