MarcieFess
Registered User.
- Local time
- Today, 09:30
- Joined
- Oct 25, 2012
- Messages
- 107
I've created a form, called frmReportsMenu. From this form, the users will be able to print the various forms required for client company stores.
On the form there is currently 1 field: a combo box with the label Store Name (combo box is named cboStoreKey).
The control source for this combo box is:
SELECT [Store Information].[Store Key], [Store Information].[Store Name] FROM [Store Information] ORDER BY [Store Name];
There is a button that says "Print HMIS Report"
Here's the VBA code in its entirety for this form:
Option Compare Database
'------------------------------------------------------------
' btnPrintHMISRpt_Click
'
'------------------------------------------------------------
Private Sub btnPrintHMISRpt_Click()
On Error GoTo btnPrintHMISRpt_Click_Err
Exit Sub
DoCmd.OpenReport "HmisReport", acViewPreview, , "[Store Key] = " & Me.cboStoreKey
DoCmd.RunCommand acCmdPrintPreview
btnPrintHMISRpt_Click_Exit:
Exit Sub
btnPrintHMISRpt_Click_Err:
MsgBox Error$
If Me.cboStoreKey = "" Then MsgBox ("You must select a store!")
End If
Resume btnPrintHMISRpt_Click_Exit
End Sub
When I click the button, I get a compile error: End If without block If
The line 'Private Sub btnPrintHIMSRpt_Click() has' a yellow arrow pointing to it, and the line is highlighted yellow.
The 'End If' (second line from the bottom) is selected.
I really don't understand this error. Can anyone help?
On the form there is currently 1 field: a combo box with the label Store Name (combo box is named cboStoreKey).
The control source for this combo box is:
SELECT [Store Information].[Store Key], [Store Information].[Store Name] FROM [Store Information] ORDER BY [Store Name];
There is a button that says "Print HMIS Report"
Here's the VBA code in its entirety for this form:
Option Compare Database
'------------------------------------------------------------
' btnPrintHMISRpt_Click
'
'------------------------------------------------------------
Private Sub btnPrintHMISRpt_Click()
On Error GoTo btnPrintHMISRpt_Click_Err
Exit Sub
DoCmd.OpenReport "HmisReport", acViewPreview, , "[Store Key] = " & Me.cboStoreKey
DoCmd.RunCommand acCmdPrintPreview
btnPrintHMISRpt_Click_Exit:
Exit Sub
btnPrintHMISRpt_Click_Err:
MsgBox Error$
If Me.cboStoreKey = "" Then MsgBox ("You must select a store!")
End If
Resume btnPrintHMISRpt_Click_Exit
End Sub
When I click the button, I get a compile error: End If without block If
The line 'Private Sub btnPrintHIMSRpt_Click() has' a yellow arrow pointing to it, and the line is highlighted yellow.
The 'End If' (second line from the bottom) is selected.
I really don't understand this error. Can anyone help?