G
Guest
Hello,
I'm having a problem retreiving recordset, getting "Datatype mismatch in
criteria expression" Here's the code simplified:
Dim SQL As String
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
SQL = "SELECT tblData.PartID FROM tblData " & _
"WHERE tblData.PartID=" & [Forms]![frmData]![txtPartID]
rst.Open SQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
MsgBox rst.RecordCount
What the code is suppose to do is to find how many records there are of a
specific part id (part id is a string expression, example "00535000V"). The
problem is that cannot search on a string criteria, e.g.
"[Forms]![frmData]![txtPartID]" the way I type the code.
Any suggestions on what I need to change in the SQL expression?
Thanx,
Isbjornen
PS. I've used similar code to search by number without any problems.
I'm having a problem retreiving recordset, getting "Datatype mismatch in
criteria expression" Here's the code simplified:
Dim SQL As String
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
SQL = "SELECT tblData.PartID FROM tblData " & _
"WHERE tblData.PartID=" & [Forms]![frmData]![txtPartID]
rst.Open SQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
MsgBox rst.RecordCount
What the code is suppose to do is to find how many records there are of a
specific part id (part id is a string expression, example "00535000V"). The
problem is that cannot search on a string criteria, e.g.
"[Forms]![frmData]![txtPartID]" the way I type the code.
Any suggestions on what I need to change in the SQL expression?
Thanx,
Isbjornen
PS. I've used similar code to search by number without any problems.