Pulling a parameter from a form

  • Thread starter Thread starter jokeascool
  • Start date Start date
J

jokeascool

Hello All,

I have query that pulls a parameter from a list box on a form. The
query refrences the list box like such:

Where (Take_Offs_tbl.House_Code)=[forms]![frmschedulea]![listbox8]

My question is this.

I have a for next loop that concatenates the parameter. What is the
proper syntax that the parameter should look like after the loop is
done.

Should it simply look like this:

"vb1"or"vb2"or"vb3"

Or should it look differntly. Right now the query is not working
correctly and it has something to do with this parameter.

Any help would be appreciated!

Thanks

Joe
 
it should look like that

in ("vb1","vb2","vb3")

Where (Take_Offs_tbl.House_Code) in ("vb1","vb2","vb3")
 
jokeascool said:
I have query that pulls a parameter from a list box on a form. The
query refrences the list box like such:

Where (Take_Offs_tbl.House_Code)=[forms]![frmschedulea]![listbox8]

My question is this.

I have a for next loop that concatenates the parameter. What is the
proper syntax that the parameter should look like after the loop is
done.

Should it simply look like this:

"vb1"or"vb2"or"vb3"

Or should it look differntly. Right now the query is not working
correctly and it has something to do with this parameter.


You can not use a parameter that contains SQL syntax. A
parameter must represent a single value.

Here's one way to deal with this kind of situation.
Construct your list to look like ,"vb1,vb2,vb3," and place
it in a hidden text box named txtMyList on the form. Then
use the following in the criteria row of any field in the
query so the query's WHERE ends up looking like this:

WHERE InStr(Forms!frmschedulea!txtMyList, "," &
Take_Offs_tbl.House_Code & ",") > 0
 
Back
Top