Runtime crashes

dmyoungsal

Registered User.
Local time
Yesterday, 18:48
Joined
May 1, 2016
Messages
112
In my database, I have a screen that users enter data into and once complete, they click a button to do a Print Preview. If all is good, they can click the print button and the report will print.

It works fine on my computer, but all my users that are using the Access 2013 R/T and when they click Print (from the Print Preview screen), the database closes.

Here is the code for printing when a new entry is made:

Private Sub Command376_Click()
Dim strDocName As String
Dim strWhere As String
strDocName = "rptTransCalcTruckNew"
strWhere = "[ID]=" & Me!txtID
DoCmd.OpenReport strDocName, acPreview, , strWhere
End Sub


Here is the code for printing from the Inquiry screen:

Private Sub Command118_Click()
Dim strDocName As String
Dim strWhere As String
strDocName = "rptTransCalcTruck"
strWhere = "[ID]=" & Me!txtID
DoCmd.OpenReport strDocName, acPreview, , strWhere
End Sub
 
Private Sub Command118_Click()
Dim strDocName As String
Try this:

Dim strWhere As String
strDocName = "rptTransCalcTruck"
strWhere = "[ID]=" & Me!txtID
DoCmd.OpenReport strDocName, acNormal, , strWhere
End Sub
 
Private Sub Command118_Click()
Dim strDocName As String
Try this:

Dim strWhere As String
strDocName = "rptTransCalcTruck"
strWhere = "[ID]=" & Me!txtID
DoCmd.OpenReport strDocName, acNormal, , strWhere
End Sub

+++++

It seems the only thing you changed was the variable "acNormal". This makes the report print rather than preview right?

I went down and talked with my user and the report only crashes from the routine when a new entry is made.
 
acNormal as far as I am aware is the one that will make the report print - however, taking a second look at your code it appears that the report is already showing on screen?

If that is the case, then I would say your second code should use the DoCmd.PrintOut method:

expression .PrintOut(PrintRange, PageFrom, PageTo, PrintQuality, Copies, CollateCopies)

Also, as it is only problematic on new records, I would be inclined to add
DoCmd.RunCommand accmdSaveRecord just after you have declared your variables on your first bit of code to ensure that the data has been saved to the table before the report query runs
 

Users who are viewing this thread

Back
Top Bottom