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

How can I send two different params to a query 1

Status
Not open for further replies.

ToyFox

Programmer
Jan 24, 2009
161
US
I have a query that I want to use for a report and also to load a listbox. This would depend on a value selected from a combo box. The combo box is on two distinct forms.
How can i get the value from the form into the query as a parameter. I have an IIF form1!dropdown = "",form2!dropdown,form1!dropdown)

The parameter prompt comes up after I select the value.
Not sure how to best do this.
 
I ended up using two different queries, this is not the way I wanted it to work, but I dont have the time to tinker right now.
 

You could use the result of a function as the WHERE criteria in your query.


Randy
 
To expand on randy700's suggestion, something like:
Code:
Public Function CboSelection() as string
Dim frmImp As Form

CboSelection = "" ' default value
If CurrentProject.AllForms("YourForm1").IsLoaded = True then
   set frmImp = Forms!YourForm1
   If frmImp.CurrentView > 0 Then
       CboSelection = yourform1cboname.value
   end if
else if CurrentProject.AllForms("YourForm2").IsLoaded = True then
   set frmImp = Forms!YourForm2
   If frmImp.CurrentView > 0 Then
       CboSelection = yourform2cboname.value
   end if

end if
End Function
should do what you're looking for.

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
excellent, i'll give it a try. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top