NYFashionToGo
Technical User
I am running some code from excel to print sales receipts out.... In sequence with some shipping labels... After this routine runs.. If I need to open up access ( for whatever reason) it is giving me a message saying I do not have exclusive access to the database at this time....
Is there anything I am doing wrong here in this code below that will get rid of that message and close the connection. So I can open it up and work inside...
Thanks
Sub Step7PrintSalesReceipt()
Dim appAcc As Object
Set appAcc = CreateObject("Access.Application")
appAcc.Visible = False
appAcc.OpenCurrentDatabase ("C:\Documents and Settings\Chris\My Documents\NYFashionToGo\NYFOrderProcessingNewEdition.mdb")
On Error GoTo ErrorHandler
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='PRIORITY'"
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='FIRST'"
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='EXPRESS'"
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='INTLAIRLETTER'"
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='INTLGPM'"
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='INTLGEM'"
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='INTLAIRPARCEL'"
ExitHandler:
Exit Sub
ErrorHandler:
' This traps the Output to Error message
If Err = 2501 Then
Resume ExitHandler
Else
MsgBox Err.Description
Resume ExitHandler
End If
appAcc.Quit
End Sub
Is there anything I am doing wrong here in this code below that will get rid of that message and close the connection. So I can open it up and work inside...
Thanks
Sub Step7PrintSalesReceipt()
Dim appAcc As Object
Set appAcc = CreateObject("Access.Application")
appAcc.Visible = False
appAcc.OpenCurrentDatabase ("C:\Documents and Settings\Chris\My Documents\NYFashionToGo\NYFOrderProcessingNewEdition.mdb")
On Error GoTo ErrorHandler
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='PRIORITY'"
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='FIRST'"
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='EXPRESS'"
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='INTLAIRLETTER'"
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='INTLGPM'"
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='INTLGEM'"
appAcc.DoCmd.OpenReport "Sales Receipt", acPrint, , "[ShippingLabel]='INTLAIRPARCEL'"
ExitHandler:
Exit Sub
ErrorHandler:
' This traps the Output to Error message
If Err = 2501 Then
Resume ExitHandler
Else
MsgBox Err.Description
Resume ExitHandler
End If
appAcc.Quit
End Sub