Open form in different ways depending on Button

E

erick-flores

Hello all

How do I right this code:

If forms-is-open-byclickingbutton#1 then
Do something
else
Do somethins
end if

Basically I am opening FormB from FormA. FormA has two button, both
open FormB...But I want the recordsource to change if its open from
Button1 or Button2.

Thank you in advance
 
J

John Vinson

Basically I am opening FormB from FormA. FormA has two button, both
open FormB...But I want the recordsource to change if its open from
Button1 or Button2.

Change the recordsource in the Click events of the two buttons, after
opening the form:

DoCmd.OpenForm "NameOfForm", <arguments>
Forms!NameOfFOrm.Recordsource = <whatever>

Note that you might do better to use the WhereCondition argument of
the OpenForm method to select a subset of the records, unless the two
recordsources refer to different tables (which would be a rather
strange thing to do!)

John W. Vinson[MVP]
 

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