Solved Report prints from RunReport command in Macro/turned into module (1 Viewer)

tvman5683

Registered User.
Local time
Today, 14:57
Joined
Oct 2, 2008
Messages
42
I added a RunReport cmd to a macro I used to create the report from a button on a form. Recently when I had a problem with "duplicate previoud record"
all my macros were converted to modules so code could be added to fix. I not too well verse in VBA and not sure why the report gets created but goes directly to print.

Thanks for any help you can provide


Private Sub Create_Weekly_Location_ID_Summary_Click()
On Error GoTo Create_Weekly_Location_ID_Summary_Click_Err

' _AXL:<?xml version="1.0" encoding="UTF-16" standalone="no"?>
' <UserInterfaceMacro For="Create Invoice" Event="OnClick" xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application"><Statements><Action Name="OpenForm"><Argument Name="For
' _AXL:mName">frmReports</Argument></Action></Statements></UserInterfaceMacro>
DoCmd.OpenQuery "Delete Weekly Location ID Summary", acViewNormal, acEdit
DoCmd.OpenQuery "Create Weekly Location ID Summary", acViewNormal, acEdit
DoCmd.OpenQuery "Update Invoice Total", acViewNormal, acEdit
DoCmd.OpenReport "Weekly Location ID Summary", acViewNormal, acEdit



Create_Weekly_Location_ID_Summary_Click_Exit:
Exit Sub

Create_Weekly_Location_ID_Summary_Click_Err:
MsgBox Error$
Resume Create_Weekly_Location_ID_Summary_Click_Exit

End Sub
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:57
Joined
Feb 19, 2002
Messages
42,739
acViewPreview is the option to preview
acViewNormal is the option to print (obvious, right;))

Opening queries that allow editing is EXTREMELY dangerous. Users can do ANYTHING including deleting all the rows.
DoCmd.OpenQuery "Update Invoice Total", acViewNormal, acEdit

NEVER display data using queries. Always use Reports which don't allow editing or Forms where you can prevent editing or at lease validate updates.
 

tvman5683

Registered User.
Local time
Today, 14:57
Joined
Oct 2, 2008
Messages
42
Thank You. I did not know that. As I mentioned I created this originally as a Macro that just created the tables for the report but it got converted to code. I wanted to add the "Open Report" line so I just copied the line above it and changed openquery to open report.
 

Users who are viewing this thread

Top Bottom