I have a form with four combo box that will search for a record, as follow:
Field Name "Printer" , DataType "Text"
Field Name Month" , DataType "Text"
Field Name "Year" , DataType "Number"
Field Name "Day" , DataType "Number"
code for Find Record Button:
This is only a part of the code, I have a problem with year and day since they are numbers not text I was told that i cant use this line:
I was told that there is no need to use "like", am not really sure how to do it, any help will be appreciated.
Thanks.
Field Name "Printer" , DataType "Text"
Field Name Month" , DataType "Text"
Field Name "Year" , DataType "Number"
Field Name "Day" , DataType "Number"
code for Find Record Button:
Code:
If Not IsNull(ID) And Trim(ID) <> "" Then
StrSQL = StrSQL & " And [Id] = " & [ID]
End If
If Not IsNull([txtname]) And Trim([txtname]) <> "" Then
If InStr([txtname], "*") = 0 Then
StrSQL = StrSQL & " And [Name] = '" & [txtname] & "'"
Else
StrSQL = StrSQL & " And [Name] like '" & [txtname] & "'"
End If
End If
'================================'
If Not IsNull([txtyear]) And Trim([txtyear]) <> "" Then
If InStr([txtyear], "*") = 0 Then
StrSQL = StrSQL & " And [Year] = '" & [txtyear] & "'"
Else
StrSQL = StrSQL & " And [Year] like '" & [txtyear] & "'"
End If
End If
'================================'
If Not IsNull([txtmonth]) And Trim([txtmonth]) <> "" Then
If InStr([txtmonth], "*") = 0 Then
StrSQL = StrSQL & " And [Month] = '" & [txtmonth] & "'"
Else
StrSQL = StrSQL & " And [Month] like '" & [txtmonth] & "'"
End If
End If
'================================'
If Not IsNull([txtday]) And Trim([txtday]) <> "" Then
If InStr([txtday], "*") = 0 Then
StrSQL = StrSQL & " And [Day] = '" & [txtday] & "'"
Else
StrSQL = StrSQL & " And [Day] like '" & [txtday] & "'"
End If
End If
'================================'
This is only a part of the code, I have a problem with year and day since they are numbers not text I was told that i cant use this line:
Code:
StrSQL = StrSQL & " And [Month] like '" & [txtmonth] & "'"
Thanks.