I
isbjornen
What is the proper way to write a SQL statement for a Recordset using the
Like Operator and the asterisk wildcard (*)?
Here is the SQL statement from the query (works just fine):
SELECT SOFSN.SERIAL_NUMBER
FROM SOFSN
WHERE (((SOFSN.SERIAL_NUMBER) Like "*" & [Forms]![frmRepair]![txtSerialNo]));
Here's what I'm trying to do (and I tried a zillion ways without success):
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
SQL = "SELECT SOFSN.SERIAL_NUMBER " & _
"FROM SOFSN " & _
"WHERE (((SOFSN.SERIAL_NUMBER) Like '*' &
[Forms]![frmRepair]![txtSerialNo]));"
rst.Open SQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rst.RecordCount = 1 Then
'Do something
End If
rst.Close
The txtSerialNo is a String and sometimes starts with a zero - that's what
I'm trying to capture in case no zero is entered from the start.
Example: 120 could be 0120
Thanx!
Like Operator and the asterisk wildcard (*)?
Here is the SQL statement from the query (works just fine):
SELECT SOFSN.SERIAL_NUMBER
FROM SOFSN
WHERE (((SOFSN.SERIAL_NUMBER) Like "*" & [Forms]![frmRepair]![txtSerialNo]));
Here's what I'm trying to do (and I tried a zillion ways without success):
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
SQL = "SELECT SOFSN.SERIAL_NUMBER " & _
"FROM SOFSN " & _
"WHERE (((SOFSN.SERIAL_NUMBER) Like '*' &
[Forms]![frmRepair]![txtSerialNo]));"
rst.Open SQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rst.RecordCount = 1 Then
'Do something
End If
rst.Close
The txtSerialNo is a String and sometimes starts with a zero - that's what
I'm trying to capture in case no zero is entered from the start.
Example: 120 could be 0120
Thanx!