I have a form wherein I ask the user to type in a range of dates. Once the user does that and hits 'search', Access returns data, in a list box within my form, that is between the date ranges that the user typed in. I use the following code:
Private Sub Command22_Click()
Dim strSQL As String
Dim strSQL2 As String
strSQL = "SELECT tblUsers.ID, tblUsers.Birthday, tblUsers.Name FROM tblUsers WHERE [Birthday]>= #" & _
Me!StartDate & "# AND [Birthday]<= #" & Me!EndDate & "# ORDER By tblUsers.Birthday DESC;"
strSQL2 = "SELECT COUNT([ID]) FROM tblUsers WHERE [Birthday]>= #" & _
Me!StartDate & "# AND [Birthday]<= #" & Me!EndDate & "#;"
With Me
.List20.RowSource = strSQL
.List26.RowSource = strSQL2
End With
End Sub
My question: I want to be able to print out the results to a report. How do i do that?
I have tried using a public strQL that is used in the form and then by the report and it doesn't work. I have tried to create a temporary table that once it is created it is used by the report's recordsource property in order to populate the report but It still doesn't work.
Any suggestions?
Private Sub Command22_Click()
Dim strSQL As String
Dim strSQL2 As String
strSQL = "SELECT tblUsers.ID, tblUsers.Birthday, tblUsers.Name FROM tblUsers WHERE [Birthday]>= #" & _
Me!StartDate & "# AND [Birthday]<= #" & Me!EndDate & "# ORDER By tblUsers.Birthday DESC;"
strSQL2 = "SELECT COUNT([ID]) FROM tblUsers WHERE [Birthday]>= #" & _
Me!StartDate & "# AND [Birthday]<= #" & Me!EndDate & "#;"
With Me
.List20.RowSource = strSQL
.List26.RowSource = strSQL2
End With
End Sub
My question: I want to be able to print out the results to a report. How do i do that?
I have tried using a public strQL that is used in the form and then by the report and it doesn't work. I have tried to create a temporary table that once it is created it is used by the report's recordsource property in order to populate the report but It still doesn't work.
Any suggestions?