how do I pass value to a query from a form?

G

Guest

I am passing a parameter from form A to form B. Form B uses this parameter to
run a query that uses this parameter.

I am able to pass the parameter from form A to B, however, the query on
which form B is based, doesn't take into account this parameter and I get
window to 'Enter parameter value". The parameter is defined as public.

Any ideas?

Thank you,
-Me
 
G

Guest

If the parameter defined in a Module as Global, then you can create a
function that will return the parameter, and then you can use the function in
the query

Function FunctionName()
FunctionName = ParameterValue
End Function

In the Query
Select * From TableName Where FieldName = FunctionName()
========================
Or, if the form is still open you can add the field path to the query

Select * From TableName Where FieldName = Forms![FormName]![FieldName]
 
G

Guest

Ofer,

Thanks for the reply! I am trying my best to implement what you suggested,
but stil its not working.

I agree with you, what you have mentioned here should work. But I am running
out of ideas as to why it isn't working.

Thank you,
-Me


Ofer said:
If the parameter defined in a Module as Global, then you can create a
function that will return the parameter, and then you can use the function in
the query

Function FunctionName()
FunctionName = ParameterValue
End Function

In the Query
Select * From TableName Where FieldName = FunctionName()
========================
Or, if the form is still open you can add the field path to the query

Select * From TableName Where FieldName = Forms![FormName]![FieldName]

--
\\// Live Long and Prosper \\//
BS"D


Me said:
I am passing a parameter from form A to form B. Form B uses this parameter to
run a query that uses this parameter.

I am able to pass the parameter from form A to B, however, the query on
which form B is based, doesn't take into account this parameter and I get
window to 'Enter parameter value". The parameter is defined as public.

Any ideas?

Thank you,
-Me
 
G

Guest

Can you post what you have?

--
\\// Live Long and Prosper \\//
BS"D


Me said:
Ofer,

Thanks for the reply! I am trying my best to implement what you suggested,
but stil its not working.

I agree with you, what you have mentioned here should work. But I am running
out of ideas as to why it isn't working.

Thank you,
-Me


Ofer said:
If the parameter defined in a Module as Global, then you can create a
function that will return the parameter, and then you can use the function in
the query

Function FunctionName()
FunctionName = ParameterValue
End Function

In the Query
Select * From TableName Where FieldName = FunctionName()
========================
Or, if the form is still open you can add the field path to the query

Select * From TableName Where FieldName = Forms![FormName]![FieldName]

--
\\// Live Long and Prosper \\//
BS"D


Me said:
I am passing a parameter from form A to form B. Form B uses this parameter to
run a query that uses this parameter.

I am able to pass the parameter from form A to B, however, the query on
which form B is based, doesn't take into account this parameter and I get
window to 'Enter parameter value". The parameter is defined as public.

Any ideas?

Thank you,
-Me
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top