I am making a program that runs out of Outlook on the front end and uses an Access database as the backend.
I have a field in the database that is a test number. It is a 8 digit number set up in the following format ###-###-##
The user will know the first 3 digits and the last 2 digits so I want to search knowing these five digits and allowing
the middle three digits to be anything, however, I have tried using *, #, and % as wildcards but it always
returns nothing. My code is below. Any help would be much appreciated.
Private Sub CommandButton1_Click()
Dim count As Integer
Dim stSQL As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open stdbName
If TextBox1.Value = "" Then
MsgBox "Please Input a Product Number"
Else
stSQL = "SELECT * FROM [Report Info] WHERE [Test Number] = '" & TextBox1.Value & "-%%%-99'"
rs.CursorLocation = adUseClient
rs.Open stSQL, cn
count = rs.RecordCount
rs.Close
End If
End Sub
-joker16
I have a field in the database that is a test number. It is a 8 digit number set up in the following format ###-###-##
The user will know the first 3 digits and the last 2 digits so I want to search knowing these five digits and allowing
the middle three digits to be anything, however, I have tried using *, #, and % as wildcards but it always
returns nothing. My code is below. Any help would be much appreciated.
Private Sub CommandButton1_Click()
Dim count As Integer
Dim stSQL As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open stdbName
If TextBox1.Value = "" Then
MsgBox "Please Input a Product Number"
Else
stSQL = "SELECT * FROM [Report Info] WHERE [Test Number] = '" & TextBox1.Value & "-%%%-99'"
rs.CursorLocation = adUseClient
rs.Open stSQL, cn
count = rs.RecordCount
rs.Close
End If
End Sub
-joker16