Shady Baby
New member
- Local time
- Today, 03:00
- Joined
- Jun 24, 2008
- Messages
- 6
RESOLVED
Hi,
I'm having a problem with a SQL Statment.
I have a ListBox which has 5 columns filled with text from the table "Test"
So, the ListBox has hundreds of filled rows from the table "Test", what I want
is when someone introduces, for example "F" on the textbox txtPN
the ListBox only get filled with the data where the field "model"
starts with "F" (the value introduced on the txtbox)
I hope I could explain well. Thanks
SOLUTION
Looks like we don't use percentage (%) on VBA on the LIKE Statment, but asterisks (*)
So, the right statment would be:
Hi,
I'm having a problem with a SQL Statment.
I have a ListBox which has 5 columns filled with text from the table "Test"
Code:
Private Sub cmdNP_Click()
If IsNull(Me.txtNP) Then
MsgBox "Missing Text"
Else
SQL = "SELECT * FROM Ricoh WHERE ([Ricoh.model] LIKE " & me.txtNP & " '%');"
Me.lstRicoh.RowSource = SQL
Me.lstRicoh.Requery
End If
End Sub
is when someone introduces, for example "F" on the textbox txtPN
the ListBox only get filled with the data where the field "model"
starts with "F" (the value introduced on the txtbox)
I hope I could explain well. Thanks
SOLUTION
Looks like we don't use percentage (%) on VBA on the LIKE Statment, but asterisks (*)
So, the right statment would be:
Code:
SQL = "SELECT * FROM Ricoh WHERE ([Ricoh.Model] Like '*" & Forms!Ricoh.txtNP & "*');"
Last edited: