Db-why-not
Registered User.
- Local time
- Today, 17:29
- Joined
- Sep 17, 2019
- Messages
- 159
I have a form with a few combo boxes, that will open up different reports and filter the report by month and year. I set the criteria in my queries for the reports to equal the value in the comboboxes. I I have a 3 combos boxes. One combo box is for the type of report, then one combo box is month, then one is for year. I will probably add another combo box for Auditor name also. The user must select the type of report they want. For the Month and year combo boxes I want it to be optional to select those so that they can show all months or all years. I'm not sure how to get it that way because I keep getting errors. I tried adding this code but it causes a problem somewhere else and it doesn't work perfectly.
I also get an error with this code after adding the above code. I have a label on my report that gets the caption from the date and month that is selected from the combo box. When nothing is selected in the month or year combobox it causes an error for that code. I would like the caption just to be blank if nothing is selected for the comboboxs.
I'm wondering how I should fix this error with the caption? Or should I just do this combobox differently. Should I add a Selection "All Months", then add selection "All Years" to my combo boxes? If I add All month selection to my combobox how can I get it to show all months in my query? I'm not sure what the best way would be to do that.
Code:
WHERE (((Month([dtfixed]))=[Forms]![AuditAccuracy_Reports]![cboMonth]) AND ((Year([dtFixed]))=[Forms]![AuditAccuracy_Reports]![cboYear])) OR (([Forms]![AuditAccuracy_Reports]![cboYear] Is Null) AND (([Forms]![AuditAccuracy_Reports]![cboMonth]) Is Null));
I also get an error with this code after adding the above code. I have a label on my report that gets the caption from the date and month that is selected from the combo box. When nothing is selected in the month or year combobox it causes an error for that code. I would like the caption just to be blank if nothing is selected for the comboboxs.
Code:
Private Sub Report_Open(Cancel As Integer)
Me.lbMonth.Caption = MonthName(Forms!AuditAccuracy_Reports!cboMonth) & " " & Forms!AuditAccuracy_Reports!cboYear
End Sub
I'm wondering how I should fix this error with the caption? Or should I just do this combobox differently. Should I add a Selection "All Months", then add selection "All Years" to my combo boxes? If I add All month selection to my combobox how can I get it to show all months in my query? I'm not sure what the best way would be to do that.