Find record (not filter) based on subform value

C

Craig

Hello,

I have a form (frmGuests) with a subform (sfrmGuestRentalHistory) that lists
property rentals for a particular guest. Each record in the subform has a
unique identifier rentalID.

I have a second form (frmRentals) with a subform (sfrmTransactions) that
lists transactions for each rental. Each record in the main form has the
same unique identifier, rentalID.

I would like a command button on frmGuest that will display, in frmRental,
the rental that is hightlighted in sfrmGuestRentalHistory.

I am able to partially accomplish this using the command button wizard ---
but the code created by the wizard performs a filter, rather than a true
find. I still want all the records available when frmRentals opens.

Can someone please provide me with a template on how to do this? I imagine
it is some combination of DoCmd.OpenForm and DoCmd.FindRecord, but I can't
seem to get the FindRecord part to work (it opens the form and does not find
the record, but no error messages).

Any help is greatly appreciated!

Thanks,
Craig
 
K

Klatuu

Use the OpenArgs argument of the OpenForm method when you open frmRental to
pass it the RentalID.
Then in the Load event of frmRental, navigate to that record:

With Me.RecordsetClone
.FinFirst "[RentalID] = " & Me.OpenArgs
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top