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

Using a variable to set a Form reference...

Status
Not open for further replies.

hoialmen

MIS
Dec 10, 2001
53
US
Hi All!

I have a few forms in an application I am working on that have a ComboBox that allows users to select from a list of customers. Now, if a user is unable to find the customer they are looking for, there is a button they can click that opens an "Advanced Search" form where they can search any part of a customer name (i.e. search "ABC" for "ABC Corp."). What I would like to be able to do is, once a user has found the customer they are looking for in the advanced search, assign the combobox on the "Source Form" to the customer name they have selected.

My thought process on this is to have a global variable:

Global AdvSourceForm as Form

that is assigned when a user clicks the "Advanced Search" button. Then, once the user has selected a customer name from the "Advanced Search" form, there would be a Sub Function that updated the Customer combobox on the source form with something like:

Forms!AdvSourceForm.cmbCustomer.Value = [CustomerID]

My problem is assigning the value to Global AdvSourceForm. I tried using:

AdvSourceForm = Me.Name (from source form)

This gives me a "Invalid use of property" compile error.

If anyone understands what it is that I'm trying to do and has any helpful advice, I would greatly appreciate the help.

Thanks!

Nate
 
Hi Nate!

When you open the Advanced search form in the button click, pass the form name:

DoCmd.OpenForm "AdvancedSearch", , , , , , Me.Name

Then in the advanced search form you would code:

Forms(Me.OpenArgs)!cmbCustomer.Value = CustomerId

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top