|
-
November 10th, 1999, 12:28 PM
#1
SQL Like in VB
I have a form that I need to add the ability to search for mult parameters in a query by the end user. I am having trouble with running an SQL query from my app with the LIKE operator
For instance:
Query from three text boxes; txtFirm , txtFirstName, txtLastName
Access database table called KDetail Using ADO control w/ Access 2000
---------------
Private Sub cmdSearch_Click
Dim aSQL as string '
Dim A, B, C as String
A= txtFirm
B= txtFirstName
C= txtLastName
aSQL = "SELECT * FROM KDetail WHERE Firm Like '"&(A)&"' AND FirstName Like" & _
" '"&(B)"' AND LastName Like '"&(C)"'"
If adoKDetail.Recordset.RecordCount = 0 Then
msgbox("No Record Found")
End If
End Sub
-----------------
When the code runs it doesn't allow for partial information ie Stev* for Steve
I only get the msgbox "No Record Found"
Bill
-
November 10th, 1999, 01:23 PM
#2
Re: SQL Like in VB
First, speaking explicitly to make the routine 'clean' the lines:
a=txtfirm
b=txtfirstname
c=txtlastname
should be changed to:
a=txtfirm.text
b=txtfirstname.text
c=txtlastname.text
Second, as a test, search explicitly for "Stev*" as noted. It should allow it. Explicitly add the * in the SQL.
-
November 10th, 1999, 08:24 PM
#3
Re: SQL Like in VB
Use %, do not use *
This is feature of ADO !!!
-
November 11th, 1999, 03:56 PM
#4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|