Hi,
I am trying to run an SQL query to select all of the records from a query with JobDates matching a date entered into a text box on a form. The text box contents is automatically populated by date().
However it doesnt seem to find any matching records, even when I am sure there are records with the same JobDate.
The code:
**********************************
Dim strInput As Date
Dim db As Database
Dim rs As ADODB.Recordset
Dim strSQL As String
stDocName = "JobsOverdue"
strInput = txtDate.Value
Set rs = New ADODB.Recordset
rs.ActiveConnection = CurrentProject.Connection
stLinkCriteria = "[JobDate]= #" & strInput & "#"
strSQL = "SELECT * FROM JobsBooked2 WHERE " & stLinkCriteria
Set db = CurrentDb
'Open the recordset
rs.Open strSQL
If (rs.EOF) Then
MsgBox "There are currently no oustanding bookings as of " & strInput & "", vbExclamation
Else
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
End If
Set rs = Nothing
Set db = Nothing
**************************************
Thanks for any help,
- Paul
PS. There are no errors, just not finding any records...
I am trying to run an SQL query to select all of the records from a query with JobDates matching a date entered into a text box on a form. The text box contents is automatically populated by date().
However it doesnt seem to find any matching records, even when I am sure there are records with the same JobDate.
The code:
**********************************
Dim strInput As Date
Dim db As Database
Dim rs As ADODB.Recordset
Dim strSQL As String
stDocName = "JobsOverdue"
strInput = txtDate.Value
Set rs = New ADODB.Recordset
rs.ActiveConnection = CurrentProject.Connection
stLinkCriteria = "[JobDate]= #" & strInput & "#"
strSQL = "SELECT * FROM JobsBooked2 WHERE " & stLinkCriteria
Set db = CurrentDb
'Open the recordset
rs.Open strSQL
If (rs.EOF) Then
MsgBox "There are currently no oustanding bookings as of " & strInput & "", vbExclamation
Else
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
End If
Set rs = Nothing
Set db = Nothing
**************************************
Thanks for any help,
- Paul
PS. There are no errors, just not finding any records...