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

SQL & Listbox

Status
Not open for further replies.

Tronsliver

Technical User
Sep 19, 2000
120
0
0
US
Jebry was so kind to help me with the following code I used for Rowsource in a listbox. However, I need to add another variable for seaching. The current variable it uses is "varx". I need to add an additional called "vary'. I was hoping someone could assist in properly formating the SQL string. The last line is where I need to insert "vary". So basically the function is to go to qryVacantSlots and find data based on "varx" and "vary"....thanks

sqlslots = "SELECT qryVacantSlots.Available As Open,"
sqlslots = sqlslots + " qryVacantSlots.strestrPosc As DutyPos, "
sqlslots = sqlslots + " qryVacantSlots.strestrGrade As Grade,"
sqlslots = sqlslots + " qryVacantSlots.strestrauthparadsg As Para,"
sqlslots = sqlslots + " qryVacantSlots.strestrauthlinedsg As Line,"
sqlslots = sqlslots + " qryVacantSlots.orgstruname As Unit,"
sqlslots = sqlslots + " qryVacantSlots.orgstraddresscity As City"
sqlslots = sqlslots + " FROM qryVacantSlots WHERE (((qryVacantSlots.orgstrPrNbr)"
sqlslots = sqlslots + " = '" & Format(varx) & "'));"
 
Not too sure what format(varX) refers to as far as formatting goes, but to be consistant I assume you need to change the SQL statement from

sqlslots = sqlslots + " FROM qryVacantSlots WHERE (((qryVacantSlots.orgstrPrNbr)"
sqlslots = sqlslots + " = '" & Format(varx) & "'));"


to


sqlslots = sqlslots + " FROM qryVacantSlots WHERE qryVacantSlots.orgstrPrNbr"
sqlslots = sqlslots + " = '" & Format(varx) & "' "
sqlslots = sqlslots + " Or '" & format(vary) & "';"

I believe you can get away without the Parenthesis, but you may not. In that case you'd have to add additional ones to encase the OR statement Plus one more at the beginning.

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top