Can we make this criteria in a query?

ariansman

Registered User.
Local time
Today, 08:28
Joined
Apr 3, 2012
Messages
157
We make a criteria in a query to get data from from1 like: [forms]![form1]![text1]. This requires us to have the Form1 open and there should be a data in Text1.
Can we make the criteria to either take the data from Form1 like the above, or if Form1 is not open it gets data for the criteria from another form like : [forms]![form2]![text2].
 
Something along these lines maybe? This is Air Code!
If CurrentProject.AllForms("Form1").IsLoaded = True Then
'Do something
Else
If CurrentProject.AllForms("Form2").IsLoaded = True Then
'Do something
End If

HTH
 
I suggest you create a function for this criteria and put the function into the query.

something like:
Code:
public function fnCriteria() as string

fnCriteria = ""

If CurrentProject.AllForms("Form1").IsLoaded = True Then
  fnCriteria = [forms]![form1]![text1]
Else
If CurrentProject.AllForms("Form2").IsLoaded = True Then
  fnCriteria = [forms]![form2]![text1]
End If


end function
 

Users who are viewing this thread

Back
Top Bottom