On one of my forms, you click a button that launches my ReportSales report. Using inputbox, it asks for a begin date then a end date. I want to pass those dates entered into my report as well (so it can remind them what the criteria was set at): Here is my code:
Dim Message, Title, Default, MyValue, FirstDate, SecondDate, message2
Dim stlinkcriteria As String
Message = "Enter First Date:"
Message2 = "Enter Last Date:"
Title = "Select Dates" ' Set title.
Default = Date
FirstDate = InputBox(Message, Title, Default)
SecondDate = InputBox(Message2, Title, Default)
stlinkcriteria = "[Date]>=" & "#" & FirstDate & "#" & " AND [DATE] <=" & "#" & SecondDate & "#"
Dim stDocName As String
stDocName = "ReportSales"
DoCmd.OpenReport stDocName, acPreview, , stlinkcriteria
Report_ReportSales.txtbegindate.Value = FirstDate
Report_ReportSales.txtenddate.Value = SecondDate
The last two line does not work. It doesn't pass anything. I need to pass the inputbox's values into the fields on my report. Can someone tell me what I am doing wrong?
Thanks!
--freefour
Dim Message, Title, Default, MyValue, FirstDate, SecondDate, message2
Dim stlinkcriteria As String
Message = "Enter First Date:"
Message2 = "Enter Last Date:"
Title = "Select Dates" ' Set title.
Default = Date
FirstDate = InputBox(Message, Title, Default)
SecondDate = InputBox(Message2, Title, Default)
stlinkcriteria = "[Date]>=" & "#" & FirstDate & "#" & " AND [DATE] <=" & "#" & SecondDate & "#"
Dim stDocName As String
stDocName = "ReportSales"
DoCmd.OpenReport stDocName, acPreview, , stlinkcriteria
Report_ReportSales.txtbegindate.Value = FirstDate
Report_ReportSales.txtenddate.Value = SecondDate
The last two line does not work. It doesn't pass anything. I need to pass the inputbox's values into the fields on my report. Can someone tell me what I am doing wrong?
Thanks!
--freefour