Move to specific record on subform

  • Thread starter Thread starter TheIMan
  • Start date Start date
T

TheIMan

Please help...

I have 'client' form with a subform 'orders'. I cannot write the
correct code to move directly to a specific order. I allow the user
to FIND AN ORDER. They type in the order number and I can search
through the orders table to see if it exists, then locate the correct
client, set a bookmark, and move to it. Then I set focus to the orders
tab, BUT I can't figure out how to make the application move to the
actual correct order. Let's say it's the 5th out of 10. I can only
make it go to the first order and the user is left to page through to
find the specific one. I tried using a second bookmark, but I can't
get it to work. Can anyone please help with a little code.

Thanks very much,

TheIMan
 
Sounds like you achieved the hard part: looking up the ClientID for the
order, and moving to the correct client in the main form so the order is in
the subform.

For the last step, FindFirst the record in the subform's RecordsetClone, and
then set its bookmark.

This example assumes the subform is named Sub1, and you are looking for the
record where the OrderID field has the value 99:

Dim rs As DAO.Recordset
Dim strWhere As String

strWhere = "OrderID = 99"
With Me.[Sub1].Form
Set rs = .RecordsetClone
rs.FindFirst strWhere
If rs.NoMatch Then
MsgBox "Not found in subform"
Else
.Bookmark = rs.Bookmark
End If
End With
Set rs = Nothing
 
Sounds like you achieved the hard part: looking up the ClientID for the
order, and moving to the correct client in the main form so the order is in
the subform.

For the last step, FindFirst the record in the subform's RecordsetClone, and
then set its bookmark.

This example assumes the subform is named Sub1, and you are looking for the
record where the OrderID field has the value 99:

Dim rs As DAO.Recordset
Dim strWhere As String

strWhere = "OrderID = 99"
With Me.[Sub1].Form
Set rs = .RecordsetClone
rs.FindFirst strWhere
If rs.NoMatch Then
MsgBox "Not found in subform"
Else
.Bookmark = rs.Bookmark
End If
End With
Set rs = Nothing

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.




Please help...
I have 'client' form with a subform 'orders'. I cannot write the
correct code to move directly to a specific order. I allow the user
to FIND AN ORDER. They type in the order number and I can search
through the orders table to see if it exists, then locate the correct
client, set a bookmark, and move to it. Then I set focus to the orders
tab, BUT I can't figure out how to make the application move to the
actual correct order. Let's say it's the 5th out of 10. I can only
make it go to the first order and the user is left to page through to
find the specific one. I tried using a second bookmark, but I can't
get it to work. Can anyone please help with a little code.- Hide quoted text -

- Show quoted text -

Thanks Allen , it worked perfectly! Problem solved :-)
 
Back
Top