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

Set index number of a form to a Global variable for use in query? 1

Status
Not open for further replies.

Mabjro

Programmer
Jun 3, 2003
127
0
0
US
If I determine the index number of an open form to be 3, how can I use that number in a global variable for use in a query?

Thanks,
Mabjro
 
I believe you have some control having the same name on various forms and want to use it as criterion in a query (without hardcoding the form name)...

Use a function to get the value of that control from the open form.
And use function's output as criterion:

Function fCriterion() As Long
fCriterion = Forms(YourGlobalVariable)("YourControlName")
End Function

And your query:
Select * From YourTable Where IDField = fCriterion();

Of course, this is just a basic response. But your question has no details...

HTH


[pipe]
Daniel Vlas
Systems Consultant

 
I am using a non-default instance of a form and therefore it can not be refered to by name. See the following link, it explains what I am trying to do. (quick reading, about a page) The gist of the last paragraph is that I can only refer to the form by its index in the form collection.


I figured out how to get the index number, I just do not know what to do with it.
 
With either the default or non-default instance the things are the same regarding using the index: you have to use:
Forms(3)
to refer to te open form having the index of 3
This notation is not supported in queries, so you have to write a function that would return a value. That value can be used in a query.

Pass the index to a GlobalVariable and use the GlobalVariable in the function. Just as in my previous post.

Moreover, you can work with the controls and properties of any instance of any form:

Forms(3)("ControlName") or Forms(3)(0)
Forms(3).AllowAdditions = False


HTH


[pipe]
Daniel Vlas
Systems Consultant

 
For the most part you answered my question by your second post.

Mabjro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top