I am trying to search a table for a record based upon a variable I supply. Here is the code I am using;
Dim strCust_ID As String
Dim db As Database
Dim rst As Recordset
Dim strSQL As String
Dim EQP As String
Set db = CurrentDb
Set rst = db.OpenRecordset("qryEQP"
strCust_ID = Me.DistNum
strSQL = "SELECT [CUST_CLAS2] FROM [tblEQP]"
strSQL = strSQL & "WHERE [CUST_ID] = " & strCust_ID
EQP = rst![CUST_CLAS2]
Me.txtEQPStatus = EQP
This returns " " but if I copy the SQL statement from the debug window and paste it into a new query it returns "C" which is correct.
What am I doing wrong? [sig][/sig]
Dim strCust_ID As String
Dim db As Database
Dim rst As Recordset
Dim strSQL As String
Dim EQP As String
Set db = CurrentDb
Set rst = db.OpenRecordset("qryEQP"
strCust_ID = Me.DistNum
strSQL = "SELECT [CUST_CLAS2] FROM [tblEQP]"
strSQL = strSQL & "WHERE [CUST_ID] = " & strCust_ID
EQP = rst![CUST_CLAS2]
Me.txtEQPStatus = EQP
This returns " " but if I copy the SQL statement from the debug window and paste it into a new query it returns "C" which is correct.
What am I doing wrong? [sig][/sig]