Link to home
Start Free TrialLog in
Avatar of Patrick O'Dea
Patrick O'DeaFlag for Ireland

asked on

Passing Variable From Menu Form

Hi,

I have a form which I use as a Menu to control my whole system.

So I have buttons on this form that call other forms.
For instance if I want choose the button "Add New Customers" this will call frmAddCustomers.

Requirement

I use the DoCMD.OpenForm to call frmAddCustomers.  I want to pass the text "Add New Customers" to frmAddCustomers.    I.e. What ever is held as the "caption" on the menu option should be passed to frmAddCustomers.

Essentially, the end result will be that whatever "caption" is held on the main menu will also appear as a heading on the form that is called.

So, if the menu says "Add New Customer" then this should also be what appears on the form that is called.





Avatar of ErezMor
ErezMor
Flag of Australia image

in the click event of the button (say it's name is cmdAddCustomers"):
DoCmd.OpenForm "frmAddCustomres", acNormal, , , acFormAdd, acDialog, cmdAddCustomers.Caption '(you use the OpenArgs parameter to send the value)

then use the Open event of the form to set this parameter value as the form's caption:

Me.Caption = Me.OpenArgs

et voila!
Avatar of Patrick O'Dea

ASKER

Thanks Erezmore,
I have done as you instructed ... and I am sure I am nearly there but...
... the actual wording does not appear on my form!

If I insert a text box onto my form how do I make this text box display the "openargs"?

Thanks again,
Just for the record Erezmore,

When I
msgbox me.caption

in the called form It DOES display the menu name from the menu.

...therefore we are nearly there.
SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks folks - got it now