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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing parameters between forms

Status
Not open for further replies.

dnstapes

Programmer
Jul 17, 2001
38
US
My form has a few buttons that, when pressed, open up new forms. The new forms have options for filtering a subform on the first form. How can I pass parameters from the second form back to the first?

Thanks
 
The OpenArgs of the DoCmd function allows you to pass data to the form being opened. This is akin to the Tag property of controls. Your code can inspect the Me.OpenArgs for the parameters it needs to do it's job.

HTH Joe Miller
joe.miller@flotech.net
 
Just make a public sub in the first form and call it from the second when you need to pass variables to it.
 
are these variables passed by reference? Also, is it possible to pass as many variables as I want? I may need to pass more than one.

Thanks.
 
a little more clarification on my question

I'm writing a form that has a few pull down menus and a bunch of data.
After a user makes a selection in a pull down menu, a new form is opened
that asks for more user input. Based on the user input, I need to apply
filters to the first form. I think it would be most beneficial to me if
I could pass the information needed to apply the filter back to the
original form, since I may need to use it later. The original form
stays open while the second one is being manipulated by the user.
Currently, I'm opening the second form as an acDialog:

Dim stDocName As String

stDocName = "HA_Family_Selector"
DoCmd.OpenForm stDocName, , , , , acDialog

Inside the second form (HA_Family_Selector), I need to get the value of
ComboFamily.Name back to the original form.

I've tried a variety of different methods to get this to work, but I
haven't had any success yet. How would you do this?

Thanks,
Dana

 
here is my two cents

Create a new module
you know that last tab Modules

put this nere the top of the module

Global variable1, variable2 ' etc.
' you can have as many as you want

make sure you save it when you are done.
I just leave it Module1

Now in your form just use like so

variable1 = what_ever_you_want
variable2 = Something_else
variable3 = Me!somefield * a_number + wahtever

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
In the header of the module attached to the original form
declare the variables needed.

Dim StrName As String

Then create the procedure used to receive the variables (in this case just Name)

Public Sub GetHAFamilySelector(Name As String)

StrName = Name

End Sub

You could enter more script like applying the filter etc....
But I won't go there right now.

Use the AfterUpdate event on the combobox in the dialog.
In the module attached write:

[Form_Original].GetHAFamilySelector(Me.Name)

Hope this helps you.

If you can't figure out how to solve the problem, mail me.

Grtz,
Kalin

Kalin@dds.nl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top