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.





Patrick O'DeaAsked:
Who is Participating?
 
ErezMorCommented:
for labels and captions you can choose either the open or load events.
if you're still having trouble, can you send the actual code you are using?
0
 
ErezMorCommented:
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!
0
 
Patrick O'DeaAuthor Commented:
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,
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Patrick O'DeaAuthor Commented:
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.
0
 
Rey Obrero (Capricorn1)Commented:
21Dewsbury,

use the Load event of the form to set the caption

private sub form_load()
if me.openargs & ""<>"" then
  me.caption=me.openargs
end if

end sub
0
 
Patrick O'DeaAuthor Commented:
Thanks folks - got it now
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.