Query Parameters and form's collection index

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I use the form's collection index to refer to a form in the criteria
of a query?

Attempted [Forms(0)]![Fieldname] this did not work.

Thanks
 
How can you be sure that the form you want is always the first in the
collection?
 
These are being used off of a menu type form. I two different menu forms,
for two groups of people. I want to use the same queries and parameters off
of the two different menus. They would both be form 0. Right now I have two
queries that are the same except for the form name in the parameters.

Douglas J. Steele said:
How can you be sure that the form you want is always the first in the
collection?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



n2nature said:
How can I use the form's collection index to refer to a form in the criteria
of a query?

Attempted [Forms(0)]![Fieldname] this did not work.

Thanks
 
Thanks for the suggestion. The criteria on the query would not accept this
format. gave an error about invalid . or ! or )

Nikos Yannacopoulos said:
Try:

Forms(0)![FieldName]

HTH,
Nikos
How can I use the form's collection index to refer to a form in the criteria
of a query?

Attempted [Forms(0)]![Fieldname] this did not work.

Thanks
 
You will need to write a simple piece of code as follows:

Function CurrentFormValue(strFieldName As String) As String

CurrentFormValue = Forms(0)(strFieldName)

End Function

In the query you do the following

Expr1: currentformvalue("CategoryName")


This allows you to parameterise the field name, but in your example this is
not required. You could take it a stage further and parameterise the form
nam,e .. . . .


Regards
 
You will need to write a simple piece of code as follows:

Function CurrentFormValue(strFieldName As String) As String

CurrentFormValue = Forms(0)(strFieldName)

End Function

In the query you do the following

Expr1: currentformvalue("CategoryName")


This allows you to parameterise the field name, but in your example this is
not required. You could take it a stage further and parameterise the form
nam,e .. . . .


Regards
 
Back
Top