You don't need FindFirst at all:
docmd.openform "frmCabs", WhereCondition:="AANo=" & Me.AANo
Form.Recordset.FindFirst
Hi
I have a report with a simple DblClick event on a field to open a form at the record I have just double clicked...
Using the same principle, I want to put a command button on a sales form which when clicked, opens the product detail form related to that sale, but I'm missing something that is stopping it working...
I'm thinking that it may be because the succesful find.first in the first example is based upon the field in the report that I am double clicking, whereas the new one I am trying to work out is just a simple command button.
Your help would be appreciated.
Many thanks
5 answers
Sort by: Most helpful
-
Tom van Stiphout 1,696 Reputation points MVP
2021-01-29T14:03:26.74+00:00 -
LEllefson 76 Reputation points
2021-01-29T17:27:31.597+00:00 Try:
"AANo=" & Me.Cab.AANo because Me refers to frmCabs which contains Cab as a tab control.
-
LEllefson 76 Reputation points
2021-02-01T14:13:24.283+00:00 Then try:
"AANo=Forms![frmVehicleSales]![frmCabs]![Cab]![AANo]"
-
LEllefson 76 Reputation points
2021-02-01T16:28:03.257+00:00 Oh sorry, AANo might need to be bracketed like:
"[AANo] = Forms![frmVehicleSales]![frmCabs]![Cab]![AANo]"
-
LEllefson 76 Reputation points
2021-02-01T17:32:30.187+00:00 Going back and looking at your original question, it appears you are trying to open frmCabs again for a second time using criteria, but it is already open as a SubForm of frmVehiclesSales. You can't open it again so you need to create a different form.
- Open your navigation pane
- Copy frmCabs.
- Rename the copied form frmViewCab
- Try DoCmd.OpenForm "frmViewCab", acNormal, , "[AANo] = Forms![frmVehicleSales]![frmCabs]![Cab]![AANo]" on your command button
This should open frmViewCab in a separate window using the criteria you want.