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!

can't figure out how set where clause [ field] as a varible

Status
Not open for further replies.

littledude

Programmer
Apr 24, 2002
2
US

a = Me.cboSearch.Value
sSQL = "select * from [tblLessee] where [a] = '" & Me.txtSearch & "' "
ors.Open sSQL, oConn, adOpenStatic, adLockReadOnly

 
a = Me.cboSearch.Value
sSQL = "select * from [tblLessee] where [a] = '" & Me.txtSearch & "' "
ors.Open sSQL, oConn, adOpenStatic, adLockReadOnly


Sorry OM I'm struggling with what your actual problem is here

a = Me.cboSearch.Value
This seem to be saying [a] is a module variable set by the comboBox ( By the way .Value is the dafault property so you don't need to type it at all. )

Yet the SQL string seems to be using [a] as the name of the field in the table. ( The [something] that follows WHERE should be the name of the field in the tblLessee that you're looking to match against the criteria in the txtString control. )

So:-
sSQL = "SELECT * FROM tblLessee WHERE [a] = '" & txtSearch & "';"

should work fine if txtString is the NAME of the control on the form.
Note this will find EXACT matches only.


G LS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top