Me again... 
I have a form with a combobox at the top. This shows the customer name and has a hidden customer ID field. There is also a date picker control. Both of these affect a listbox control that shows records associated with sales order line details. The two comboboxes filter the results in the list box via the OnChange (or similarly named) events.
What I'm trying to do now is have a button that opens a report with only the filtered records in the list box. I already have a report that shows the unfiltered record set, and my current code seems to apply the date filter correctly.
The problem is that I'm prompted for the Customer ID (SalesOrder.Customer_ListID) before the report is opened. If I leave it blank, I get no records. If I enter a known customer ID, I get records that are filtered only by date.
Here's the button event:
As a sidenote, I've seen that forms and such should be named using more common conventions like frmFormName, rptReportName, etc. Can someone tell me if changes to these names will propagate through the code, queries, and forms - or will I have to change these names in multiple places?
Much appreciation...
-Sparky
I have a form with a combobox at the top. This shows the customer name and has a hidden customer ID field. There is also a date picker control. Both of these affect a listbox control that shows records associated with sales order line details. The two comboboxes filter the results in the list box via the OnChange (or similarly named) events.
What I'm trying to do now is have a button that opens a report with only the filtered records in the list box. I already have a report that shows the unfiltered record set, and my current code seems to apply the date filter correctly.
The problem is that I'm prompted for the Customer ID (SalesOrder.Customer_ListID) before the report is opened. If I leave it blank, I get no records. If I enter a known customer ID, I get records that are filtered only by date.
Here's the button event:
Code:
Private Sub btnPrintPreview_Click()
On Error GoTo Err_btnPrintPreview_Click
Dim stDocName As String
stDocName = "Open Sales Orders by Customer"
strWhereCondition = "SalesOrder.Customer_ListID = '" & Me.cboCustomer.Value & "'" & " AND SalesOrder.DueDate <= DateValue('" & Me.toDateFilter.Value & "')"
strOpenArgs = ""
DoCmd.OpenReport stDocName, acPreview, , strWhereCondition, , strOpenArgs
Exit_btnPrintPreview_Click:
Exit Sub
Err_btnPrintPreview_Click:
MsgBox Err.Description
Resume Exit_btnPrintPreview_Click
End Sub
As a sidenote, I've seen that forms and such should be named using more common conventions like frmFormName, rptReportName, etc. Can someone tell me if changes to these names will propagate through the code, queries, and forms - or will I have to change these names in multiple places?
Much appreciation...
-Sparky