I have a form that has many fields and when the user enters data and tabs off the field a select statement is dynamically built to query the table(s). I have one problem where I have a date range the user can enter, and the fields on the screen are of type date. They are going against a column in the table that is of date/time. The column contains some data that if manually entered stores a short date, but in some cases it gets timestamped with the currrent datetime. Here is my dilemma. Lets say I have 4 records in this table with the following dates.
10/01/2009 09:10:25
10/01/2009
10/01/2009 12:12:34
10/01/2009
If the user enters 10/01/09 and 10/01/09 they only get the 2,4 records.
If they enter 10/01/09 and 10/02/09 they get all four records.
Here is my dynamic code for adding the date fields to my select statement in my vb code.
If Not IsNull(Me.SrchLastCDate1) And Not IsNull(Me.SrchLastCDate2) Then
'ChangeSearchType
Cond = Cond & " AND LeadContacts.ContactDate BETWEEN '" & Me.SrchLastCDate1 & "' AND '" & Me.SrchLastCDate2 & "'"
End If
The LeadContacts.ContactDate is the field in the database. the two Me. fields are on the screen. What do I need to add to make this work without user having to enter one future date. Rember this is a dynamic string that I'm building called "Cond" for my select. I have tried adding functions to the database column to just reference a short date, but keep getting compile and debug errors.
10/01/2009 09:10:25
10/01/2009
10/01/2009 12:12:34
10/01/2009
If the user enters 10/01/09 and 10/01/09 they only get the 2,4 records.
If they enter 10/01/09 and 10/02/09 they get all four records.
Here is my dynamic code for adding the date fields to my select statement in my vb code.
If Not IsNull(Me.SrchLastCDate1) And Not IsNull(Me.SrchLastCDate2) Then
'ChangeSearchType
Cond = Cond & " AND LeadContacts.ContactDate BETWEEN '" & Me.SrchLastCDate1 & "' AND '" & Me.SrchLastCDate2 & "'"
End If
The LeadContacts.ContactDate is the field in the database. the two Me. fields are on the screen. What do I need to add to make this work without user having to enter one future date. Rember this is a dynamic string that I'm building called "Cond" for my select. I have tried adding functions to the database column to just reference a short date, but keep getting compile and debug errors.