query function to take multiple text box value as criteria

  • Thread starter Thread starter msmuzila
  • Start date Start date
M

msmuzila

I have a query that take in the value of one text box through a fuction
which makes sure the forms is already loaded:

Here is the query criteria:
Combo30(33)

Now i want the criteria to have multiple text boxes

Here is the function:

Public Function GetCombo30(ByVal lngID As Long) As Long
On Error Resume Next
Dim lngCombo30 As Long

' You'll need an IsLoaded or equivilent function
If CurrentProject.AllForms("Product_Sales_Monthly").IsLoaded Then
lngCombo30 = Forms!Product_Sales_Monthly!Text42
Else
lngCombo30 = lngID
End If

GetCombo30 = lngCombo30
End Function
 
The function that you show cannot return "multiple criteria" values... it
can return only one criterion value.

Are you using this function to get the value in a WHERE statement such as
this:

WHERE FieldName = GetCombo30(33)

It's not clear to me how you're using this function, so I can't really
suggest how to use this function that you're currently using.

If you want a function like this to return some type of criterion string,
then it must return a string value. And the content of the string that it
needs to return depends entirely on how you're going to use the function in
a query. The string must be usable in a query's criterion expression; you
cannot "complete" a query's criterion syntax by this method -- in other
words, this will not work if you want the query to return the rest of the
WHERE statement:

WHERE FieldName = GetCombo30()

and GetCombo30 returns this string:
25 OR 36 OR 20

You'll need to give us more details about the query's SQL statement and how
you're running the query (is it a stored query? are you building the query
in code and then running it? do you filter the query through a
DoCmd.OpenForm (or similar method) call?).
 

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

Back
Top