|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
I would like to use the LIKE operator in a simple SQL statement. I would like to filter records in my database from values in a text box.
I have tried the code below, but it keeps coming up with a error. Can anybody tell me where I'm going wrong please. Thanks.... The code I have for my button is as follows: Private Sub cmdFilter_Click() Dim sql As String sql = "Select * from equipment where equipment_no like '% " & txtfind & " % " Data1.RecordSource = sql MSFlexGrid1.Refresh txtFind.text = MSFlexGrid1.text If txtFind = "" Then MsgBox "Equipment No Not Found" Dim all As String all = "Select * from equipment " Data1.RecordSource = all Data1.Refresh txtFind.text = "" txtFind.SetFocus Else MsgBox "Item Found" End If |
|
#2
|
|||
|
|||
|
First, don't use all caps.
Next, how to tell your problem without knowing the error you get and the line of code that causes the error?
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
When I run the command it fails on.
Msflexgrid1.refresh a message ADODC1--SYNTAX ERROR IN QUERY STRING EXPRESSION 'EQUIPMENT_NO LIKE '% A %' appears. I typed the letter A into the text box in attempt to filter the database with all the records containing a letter A. Simple, I thought. HELP---All I want to do is filter my data?????????????? PS... Can I ask why not caps? |
|
#4
|
|||
|
|||
|
All caps is considered to be "shouting".
If you are changing the sql for your adodc, you might try using adodc1.requery |
|
#5
|
|||
|
|||
|
Try:
sql = "Select * from equipment where equipment_no like '% " & txtfind & " %'" (instead of) sql = "Select * from equipment where equipment_no like '% " & txtfind & " % " |
|
#6
|
|||
|
|||
|
Thanks for the reply but it still doesn't work.
I have tested this piece of code, which works well
sql = "Select * from equipment where equipment_no like 'D% " which as you know will filter all records starting with the letter D. But what is the correct syntax for placing a variable name or a text box in place of the letter D. Please help, as I'm pulling my hair out.. It must be so simple or maybe I'm so simple. Help. Thanks.... Paulevs ![]() |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > FILTERING DATA WITH SQL USING "LIKE" |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
![]() |
|