Form.Recordset.FindFirst

Chris Parkin 1 Reputation point
2021-01-29T13:50:09.53+00:00

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...

61894-working.jpg

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...

61931-not-working.jpg

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

0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Tom van Stiphout 1,696 Reputation points MVP
    2021-01-29T14:03:26.74+00:00

    You don't need FindFirst at all:
    docmd.openform "frmCabs", WhereCondition:="AANo=" & Me.AANo


  2. 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.


  3. LEllefson 76 Reputation points
    2021-02-01T14:13:24.283+00:00

    Then try:

    "AANo=Forms![frmVehicleSales]![frmCabs]![Cab]![AANo]"


  4. 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]"


  5. 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.

    1. Open your navigation pane
    2. Copy frmCabs.
    3. Rename the copied form frmViewCab
    4. 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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.