undesired result

nur annie

lost in the rain
Local time
Today, 13:22
Joined
Sep 26, 2012
Messages
27
hi all,

can someone pls tell me what is wrong with this code..

Private Sub cmdSearch_Click()
On Error GoTo errr
Me.InspectionRecords_subform.Form.RecordSource = "SELECT * FROM InspectionRecords " & BuildFilter
Me.InspectionRecords_subform.Requery
Exit Sub
errr:
MsgBox Err.Description
End Sub

Private Function BuildFilter() As Variant
Dim varWhere As Variant
Dim tmp As String
tmp = """"

Const ConJetDate = "\#dd\/mm\/yyyy\#"

varWhere = Null

If Me.txtProductCode > "" Then
varWhere = varWhere & "[PRODUCT CODE] like " & Me.txtProductCode & " AND "
End If

If Me.txtDateFrom > "" Then
varWhere = varWhere & "([INSPECTION DATE] >= " & Format(Me.txtDateFrom, ConJetDate) & ") AND "
End If

If Me.txtDateTo > "" Then
varWhere = varWhere & "([INSPECTION DATE] <= " & Format(Me.txtDateTo, ConJetDate) & ") AND "
End If

If IsNull(varWhere) Then
varWhere = ""
Else
varWhere = " Where " & varWhere

If Right(varWhere, 5) = " AND " Then
varWhere = Left(varWhere, Len(varWhere) - 5)
End If
End If

BuildFilter = varWhere

End Function


the idea is to search data form certain range of date that i've entered... the result im getting is out of range. is there anything wrong with the code because i'm not the author... actually i'm not so good in this.


pls help me

annie
 
can you post sample dB, so one can reproduce the result?
 
hi..

last time i tried to upload my db... failed.. is there any other way since the quota is sooo small..


annie
 
Have you tried zipped the file, make a copy and remove additional items. right click and send to compressed.
 
yes of course... any other way i can post the sample of my db... i'm not a internet junkie... so pls help with this
 
yes of course... any other way i can post the sample of my db.

Why other way, is it larger than 2 MB? what is the problem u are facing?
 

Users who are viewing this thread

Back
Top Bottom