append query used by more than 1 form

PrittyMe143

Registered User.
Local time
Today, 18:54
Joined
Nov 11, 2002
Messages
16
i thought i have browsed from the Help of Access that to specify the criteria of a query which is being used by more than 1 form is this way:

(assuming the common control name of the forms is EmpID)

[forms]![Empid]

meaning, just ommit the form name.

but it didn't work. instead it was being treated as a parameter.

is my idea (a query applicable to many forms) possible?
 
You could say something like this:
If the form X is open then [form]![X]![field], else [form]![Y]![field].
I don't know the exact code, but I hope that this could get you started.
 
Create a function that returns the value you need.

Public SomeVariable As Integer

Public YourFunction() As Integer
YourFunction = SomeVariable
End Function

In an event in FormA:
SomeVariable = Me.SomeControl

In an event in FormB:
SomeVariable = Me.SomeControl

Finally, in a query:

Select ....
From ...
Where SomeField = YourFunction();

Newman's method will work only if you are building the SQL in code. The function method works no matter whether the query is a stored querydef or built in code.
 

Users who are viewing this thread

Back
Top Bottom