Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a value from multiple forms 2

Status
Not open for further replies.

techsponge

Technical User
Feb 8, 2006
37
US
I have a form frmSalesReg that can be opened from a number of other forms (frmSales, frmPlayback, frmWinner, frmmerch).


On frmSalesReg I have an unbound textbox with the following code in the OnCurrent event:

me.transtype = [forms]![frmSales]![TransType]

The question is how can I get the frmSalesReg.TransType to accept the value from the form that opened it?

me.transtype = [forms]![frmSales]![TransType]
OR
me.transtype = [forms]![frmPlayback]![TransType]
OR
me.transtype = [forms]![frmWinner]![TransType]
OR
me.transtype = [forms]![frmPlayBack]![TransType]

Cheers,
 
Setup a Global variable in a code module. This global variable can hold the value, regardless of which of your 4 forms sets it. Then, on your frmSalesReg form, you can access that global variable.

Me.transtype = MyGlobalVariable
 
Thanks rjoubert,

In the module (MyGlobalVariable) would the code look like:


me.transtype = [forms]![frmSales]![TransType]
me.transtype = [forms]![frmPlayback]![TransType]
me.transtype = [forms]![frmWinner]![TransType]
me.transtype = [forms]![frmPlayBack]![TransType]
 
No, in your code module, you would have one line that declares your global variable...

Global transType as string (or Integer, or whatever variable type you need)

Then, in the 4 forms, in the appropriate place in the code behind each form, you will set that variable to the value you need...

transType = whatever...
 
That is a little bit of overkill. You have an unbound text box on your form. I call the form 'form1' and my unbound text box is 'txtBxTransType'

Simply from the form that opens it

private cmdOpenForm1_click()
DoCmd.OpenForm "form1"
Form_Form1.txtBxTransType = me.transtype
End Sub

You can set the value of the text box (or any property) from the calling form.
 
Many thanks sir, Works like a champ!

A star for you!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top