G
Guest
When I use the wizard to create a command button (cmdNewReport)I get
something like this:
Private Sub cmdNewReport_Click()
On Error GoTo Err_cmdNewReport_Click
Dim stDocName As String
stDocName = "rptMyReport"
DoCmd.OpenReport stDocName, acPreview
Exit_cmdNewReport_Click:
Exit Sub
Err_cmdNewReport_Click:
MsgBox Err.Description
Resume Exit_cmdNewReport_Click
End Sub
On my own I would use the VBA editor to generate something like this:
DoCmd.OpenReport "rptMyReport", acPreviewView
The acPreviewView part is what shows up automatically in the VBA editor. It
seems to function similarly to acPreview, which the wizard generates.
My questions are: Do I lose or gain anything by entering the report name
directly into the DoCmd line rather than by defining it as the wizard does?
Do acPreview and acPreviewView do the same thing? What does this code
accomplish, and do I need it (or is it advisable to include it)?:
Err_cmdNewReport_Click:
MsgBox Err.Description
Resume Exit_cmdNewReport_Click
something like this:
Private Sub cmdNewReport_Click()
On Error GoTo Err_cmdNewReport_Click
Dim stDocName As String
stDocName = "rptMyReport"
DoCmd.OpenReport stDocName, acPreview
Exit_cmdNewReport_Click:
Exit Sub
Err_cmdNewReport_Click:
MsgBox Err.Description
Resume Exit_cmdNewReport_Click
End Sub
On my own I would use the VBA editor to generate something like this:
DoCmd.OpenReport "rptMyReport", acPreviewView
The acPreviewView part is what shows up automatically in the VBA editor. It
seems to function similarly to acPreview, which the wizard generates.
My questions are: Do I lose or gain anything by entering the report name
directly into the DoCmd line rather than by defining it as the wizard does?
Do acPreview and acPreviewView do the same thing? What does this code
accomplish, and do I need it (or is it advisable to include it)?:
Err_cmdNewReport_Click:
MsgBox Err.Description
Resume Exit_cmdNewReport_Click