Hello,
I'm looking to clean up some of my code, since I got a "Procedure too large" error. Basically I have a form where a user has a number of choices in combo and text boxes and based on those choices, a specific report is opened. When it was smaller, the code seemed to be fine, but as the choices have increased, the code is getting more unwieldy. Here is a small sample of the code. Can I use variables somehow instead of repeating a bunch of code with different options?
ElseIf Me.ComboDiscipline = "Cast" And Me.ComboState2 = "Alabama" Then
If IsNull(Me.TextDate1) = False And IsNull(Me.TextDate2) = False And IsNull(Me.TextMonth1) = True And IsNull(Me.TextMonth2) = True And Me.ComboReportLevel = "State" Then
DoCmd.OpenReport "RptRollupCastAlabamaState", acViewPreview, , , , OpenArgs:="QryRollupCast_Alabama_State"
ElseIf IsNull(Me.TextDate1) = True And IsNull(Me.TextDate2) = True And IsNull(Me.TextMonth1) = False And IsNull(Me.TextMonth2) = False And Me.ComboReportLevel = "State" Then
DoCmd.OpenReport "RptRollupCastAlabamaState", acViewPreview, , , , OpenArgs:="QryRollupCast_Alabama_State_MFR"
The two TextDates and TextMonths allow the user to pull a report by two different time measures. There are ~10 disciplines, ~17 states, and 4-5 report levels. Many different combinations. I assume there's a better way to do this, so any assistance is appreciated.
I'm looking to clean up some of my code, since I got a "Procedure too large" error. Basically I have a form where a user has a number of choices in combo and text boxes and based on those choices, a specific report is opened. When it was smaller, the code seemed to be fine, but as the choices have increased, the code is getting more unwieldy. Here is a small sample of the code. Can I use variables somehow instead of repeating a bunch of code with different options?
ElseIf Me.ComboDiscipline = "Cast" And Me.ComboState2 = "Alabama" Then
If IsNull(Me.TextDate1) = False And IsNull(Me.TextDate2) = False And IsNull(Me.TextMonth1) = True And IsNull(Me.TextMonth2) = True And Me.ComboReportLevel = "State" Then
DoCmd.OpenReport "RptRollupCastAlabamaState", acViewPreview, , , , OpenArgs:="QryRollupCast_Alabama_State"
ElseIf IsNull(Me.TextDate1) = True And IsNull(Me.TextDate2) = True And IsNull(Me.TextMonth1) = False And IsNull(Me.TextMonth2) = False And Me.ComboReportLevel = "State" Then
DoCmd.OpenReport "RptRollupCastAlabamaState", acViewPreview, , , , OpenArgs:="QryRollupCast_Alabama_State_MFR"
The two TextDates and TextMonths allow the user to pull a report by two different time measures. There are ~10 disciplines, ~17 states, and 4-5 report levels. Many different combinations. I assume there's a better way to do this, so any assistance is appreciated.