Danielle17
Technical User
I need to be able to choose a customer name and then a range of dates to produce a report that shows activities during those dates. I have already created a form with a combo box that contains the customer names and 2 text boxes where dates can be typed in. Here is the code that I've been experimenting with:
Private Sub cmdFindRecord_Click()
On Error GoTo Err_cmdFindRecord_Click
Dim dSQL As String
Dim stDocName As String
Dim strCrit As String
stDocName = "GageReport"
' strCrit = "SELECT Info.Customer" & _
' " FROM Info" & _
' " WHERE "[Customer] = " & Me.cboCustomer.Value" & _
' " AND(#" & Me.txtDateOne.Value & "# And #" & Me.txtDateTwo.Value & "# Between Info.CalDone AND Info.CalDue);"
'strCrit = "[Customer] = " & Me.cboCustomer.Value & _
' "[CalDue] BETWEEN #" & Me.txtDateOne.Value & "# And #" & Me.txtDateTwo.Value & "#;"
strCrit = "[Customer] = " & Me.cboCustomer & _
"AND(#" & Me.txtDateOne.Value & "# And #" & Me.txtDateTwo.Value & "# Between Info.CalDone AND Info.CalDue);"
DoCmd.OpenReport stDocName, acViewPreview, , strCrit
Exit_cmdFindRecord_Click:
Exit Sub
Err_cmdFindRecord_Click:
MsgBox Err.Description
Resume Exit_cmdFindRecord_Click
End Sub
I'm still working on it....I know how to get it to pull up a report for a certain customer but when I throw the dates in it doesn't seem to work. I'm not exactly sure how to write the part of the code for the date event.... Any help...thanks.
Private Sub cmdFindRecord_Click()
On Error GoTo Err_cmdFindRecord_Click
Dim dSQL As String
Dim stDocName As String
Dim strCrit As String
stDocName = "GageReport"
' strCrit = "SELECT Info.Customer" & _
' " FROM Info" & _
' " WHERE "[Customer] = " & Me.cboCustomer.Value" & _
' " AND(#" & Me.txtDateOne.Value & "# And #" & Me.txtDateTwo.Value & "# Between Info.CalDone AND Info.CalDue);"
'strCrit = "[Customer] = " & Me.cboCustomer.Value & _
' "[CalDue] BETWEEN #" & Me.txtDateOne.Value & "# And #" & Me.txtDateTwo.Value & "#;"
strCrit = "[Customer] = " & Me.cboCustomer & _
"AND(#" & Me.txtDateOne.Value & "# And #" & Me.txtDateTwo.Value & "# Between Info.CalDone AND Info.CalDue);"
DoCmd.OpenReport stDocName, acViewPreview, , strCrit
Exit_cmdFindRecord_Click:
Exit Sub
Err_cmdFindRecord_Click:
MsgBox Err.Description
Resume Exit_cmdFindRecord_Click
End Sub
I'm still working on it....I know how to get it to pull up a report for a certain customer but when I throw the dates in it doesn't seem to work. I'm not exactly sure how to write the part of the code for the date event.... Any help...thanks.