Hi All,
I'm using Access 2000
First i'll mention what I want to achieve and the scenario, then what i have done and the problem. This way if anyone has any alternate ideas it will be easy for them to understand (hopefully)
i'll try and explain as well as I can.
What I want to achieve
I want to be able to click a button on a form which will show a print preview of a a report, where the date criteria of the underlying query is drawn from date selections made by the user on a the form.
The scenario
I have the activeX calendar, an option group which has the options single date and between dates
I also have two text boxes, named TXT_Start and TXT_End.
If the user selects single date it sets a boolean field (TwoDates) in the form code to false. If the user selects " between dates " it sets TwoDates to true.
If Twodates = false then clicking on the calendar will only update the TXT_Start text box, otherwise if twodates = true it will alternate in updating the TXT_Start and TXT_End on each click of the calender.
What I have done to get my form to send these dates to the query which will then bring up the desired result on the report is as follows.
Clicking a button calls the code to preview the report and also creates some code placed in a TXT box called TXT_Code
The query's criteria is set to the text box TXT_Code
The code which is generated is basically
This sub is called 'Make Code'
If TwoDates = False Then
txt_Code = Me.Txt_start
ElseIf TwoDates = True Then
txt_Code = "between #" & Txt_start & "# and #"& _ Txt_End & "#"
End If
the code behind the button is
Dim stDocName As String
stDocName = "RPT_Lbls4StudPacks"
MakeCode mentioned above
DoCmd.OpenReport stDocName, acPreview
for a single date it works fine, for between dates it doesnt seem to work.
Final Thoughts
I think the reason single dates works is because it only has a date as the criteria and the query will place # around the date, whereas for the between it really is text being passed and I think Access will then place it in the criteria of the query with ' (Apostrophes), around it, which then wont work.
I also think I am doing this the long way around, i'm sure someone will come up with an answer which involves just using the where clause in the openreport or something like that, anyway over to you lot.
I hope this makes sense, and hope someone can help.
Idd
I'm using Access 2000
First i'll mention what I want to achieve and the scenario, then what i have done and the problem. This way if anyone has any alternate ideas it will be easy for them to understand (hopefully)
i'll try and explain as well as I can.
What I want to achieve
I want to be able to click a button on a form which will show a print preview of a a report, where the date criteria of the underlying query is drawn from date selections made by the user on a the form.
The scenario
I have the activeX calendar, an option group which has the options single date and between dates
I also have two text boxes, named TXT_Start and TXT_End.
If the user selects single date it sets a boolean field (TwoDates) in the form code to false. If the user selects " between dates " it sets TwoDates to true.
If Twodates = false then clicking on the calendar will only update the TXT_Start text box, otherwise if twodates = true it will alternate in updating the TXT_Start and TXT_End on each click of the calender.
What I have done to get my form to send these dates to the query which will then bring up the desired result on the report is as follows.
Clicking a button calls the code to preview the report and also creates some code placed in a TXT box called TXT_Code
The query's criteria is set to the text box TXT_Code
The code which is generated is basically
This sub is called 'Make Code'
If TwoDates = False Then
txt_Code = Me.Txt_start
ElseIf TwoDates = True Then
txt_Code = "between #" & Txt_start & "# and #"& _ Txt_End & "#"
End If
the code behind the button is
Dim stDocName As String
stDocName = "RPT_Lbls4StudPacks"
MakeCode mentioned above
DoCmd.OpenReport stDocName, acPreview
for a single date it works fine, for between dates it doesnt seem to work.
Final Thoughts
I think the reason single dates works is because it only has a date as the criteria and the query will place # around the date, whereas for the between it really is text being passed and I think Access will then place it in the criteria of the query with ' (Apostrophes), around it, which then wont work.
I also think I am doing this the long way around, i'm sure someone will come up with an answer which involves just using the where clause in the openreport or something like that, anyway over to you lot.
I hope this makes sense, and hope someone can help.
Idd