We help IT Professionals succeed at work.

Add where condition to Form's button

Ken Milam
Ken Milam asked
on
I have a basic Form question -

For lack of not knowing any better, I have created multiple copies of the same form to handle different scenarios.  For example, I have a form name f-order and I have second similar form named f-order_edit.  f-order_edit is opened when a user clicks on a button (located on a third form), which uses a criteria in the f-order_edit underlying query to one return one specific record.

There is probably a better way to handle these two scenarios with a single form + some sort of "where" expression that is associated with the button...right?   Where would this code be placed...on one of the button's events?

Thanks,
Ken
Comment
Watch Question

Software & Systems Engineer
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
How about opening a form using WHERE
Docmd.OpenForm "NameOfYourForm",,,"SomeField = SomeValue"

Open in new window

For example
Docmd.OpenForm "MyRecordForm",,,"ID = " & Me.AnotherID

Open in new window

The Docmd.OpenForm carries a "Where Condition"