Hi,
This has been driving me mad all day, I have a form with a listbox, the listbox contains a list of records from one date to another date.
I have some code in the click event of a button to open a report and pass the start date (row 1 in listbox) and the end date (last row in listbox) to the report.
The problem is that the report is blank! if I comment out the end date the report shows the records from the correct start date until the end of the records but whatever I do it will not limit the range to between start and end dates.
I've also tried using between without success.
Can anyone see what I'm doing wrong?
Cheers
This has been driving me mad all day, I have a form with a listbox, the listbox contains a list of records from one date to another date.
I have some code in the click event of a button to open a report and pass the start date (row 1 in listbox) and the end date (last row in listbox) to the report.
Code:
Private Sub Command21_Click()
Dim StartDate As Date
Dim EndDate As Date
Dim stDocName As String
Dim stLinkCriteria As String
StartDate = Me.List17.ItemData(1)
EndDate = Me.List17.ItemData(Me.List17.ListCount - 1)
stDocName = "prep details"
stLinkCriteria = "[dates] >=#" & StartDate & "#" & " AND [dates] <=#" & EndDate & "#"
'stLinkCriteria = "[dates] Between #" & StartDate & "#" & " And #" & EndDate & "#"
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
End Sub
I've also tried using between without success.
Can anyone see what I'm doing wrong?
Cheers