T
Thorson
I am new to coding and fairly new to access. I set up a dialog form that has
two control boxes, the first one is a regular text box with a date mask and
the second one is a combo box with three drop down options "DSAC"; "ORR";
"URB". I created two Command buttons, the first one is to view a query of
all the current animals, the second one is to run a macro which then opens a
report to view. If the report button is clicked I would like it to run a
different macro based on what is selected in the second combo box (DSAC, ORR,
or URB).
I'm assuming that I would use an if then else statement for this, I took a
guess and tried something but as you can see below it obviously didn't work
for several reasons. Can someone help me out?
Private Sub View_Monthly_Report_Click()
If (Me.cboDate.Value) And (cboUnit = DSAC) Then
DoCmd.RunMacro "mcrRunMonthlyInventoryReportDSAC"
Else
If (Me.cboDate.Value) And (cboUnit = ORR) Then
DoCmd.RunMacro "mcrRunMonthlyInventoryReportORR"
Else
If (Me.cboDate.Value) And (cboUnit = URB) Then
DoCmd.RunMacro "mcrRunMonthlyInventoryReportURB"
Else: MsgBox "Please Select Date and Unit"
End If
End Sub
two control boxes, the first one is a regular text box with a date mask and
the second one is a combo box with three drop down options "DSAC"; "ORR";
"URB". I created two Command buttons, the first one is to view a query of
all the current animals, the second one is to run a macro which then opens a
report to view. If the report button is clicked I would like it to run a
different macro based on what is selected in the second combo box (DSAC, ORR,
or URB).
I'm assuming that I would use an if then else statement for this, I took a
guess and tried something but as you can see below it obviously didn't work
for several reasons. Can someone help me out?
Private Sub View_Monthly_Report_Click()
If (Me.cboDate.Value) And (cboUnit = DSAC) Then
DoCmd.RunMacro "mcrRunMonthlyInventoryReportDSAC"
Else
If (Me.cboDate.Value) And (cboUnit = ORR) Then
DoCmd.RunMacro "mcrRunMonthlyInventoryReportORR"
Else
If (Me.cboDate.Value) And (cboUnit = URB) Then
DoCmd.RunMacro "mcrRunMonthlyInventoryReportURB"
Else: MsgBox "Please Select Date and Unit"
End If
End Sub