Hi! I created a new project that has the same function and use with my first project. I put a Search/Filter button in a Form. Same as what I do on my first project. But on this one. Whenever I search a data if I put NULL value on the textbox it will show me 1 record(w/c is on the first row) and when i put a value on it(w/c has the same value on the database/table) it will show me nothing? I didn't change any of the code except for the txtbox,cmdbutton,database/table,form,subform names. Please help Thanks in advanced!
BTW i had this code :
LEGEND :
Command18 -- button i use as search button
Text16 -- txtbox where i put the value that i want to search
SMS -- database/table
SMS_ValidateSubform -- form where my database/table will show
Card_Number -- name of the column on my database/table which I'm searching on.
Code:
Private Sub Command18_Click()
'Update the record source
Me.SMS_ValidateSubform.Form.RecordSource = "SELECT * FROM SMS" & BuildFilter
' Requery the subform
Me.SMS_ValidateSubform.Requery
End Sub
Code:
Private Function BuildFilter() As Variant
Dim varWhere As Variant
Dim varColor As Variant
Dim varItem As Variant
Dim intIndex As Integer
varWhere = Null ' Main filter
' Check for LIKE First Name
If Me.Text16 > "" Then
varWhere = varWhere & "[Card_Number] LIKE """ & Me.Text16 & "*"" AND "
End If
' Check if there is a filter to return...
If IsNull(varWhere) Then
varWhere = ""
Else
varWhere = "WHERE " & varWhere
' strip off last "AND" in the filter
If Right(varWhere, 5) = " AND " Then
varWhere = Left(varWhere, Len(varWhere) - 5)
End If
End If
BuildFilter = varWhere
End Function