SQL Syntax error in VBA/Access

Joined
May 6, 2011
Messages
1
Reaction score
0
Hello Guys,

Here is my code:

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
rs.ActiveConnection = cnn
rs.LockType = adLockReadOnly
rs.CursorType = adOpenDynamic
Dim strSQL As String
'Define Query and Run it
'CASE 1: For TireWidth
'If (Len(Nz(txttirewidth, "")) > 0 And Len(Nz(txttirewidthop, "")) > 0 And Len(Nz(txttirewidthvalue, "")) > 0) Then
strSQL = "SELECT TOP 10
  • .[Field3],
    • .[Field7] FROM List WHERE (
      • .[Field3] Like(" * " & Me!txttirewidthvalue & " * " ))"



        rs.Open strSQL

        'lstResult.RowSource = vbNullString

        rs.MoveFirst
        Do While Not rs.EOF
        lstResult.additem rs![Field3]
        rs.MoveNext
        Loop
        rs.Close
        'End If

        I want to use the value from textbox txttirewidth in the like operator.
        I am getting a data type error. I am not able to resolve it.

        Thanks in advance,

        Nikhil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top