Printer driver prevents record save

User avatar
Jan Karel Pieterse
Microsoft MVP
Posts: 656
Joined: 24 Jan 2010, 17:51
Status: Microsoft MVP
Location: Weert, The Netherlands

Printer driver prevents record save

Post by Jan Karel Pieterse »

Hi,

I've just encountered (and solved) the weirdest problem.

I have a button on a form that performs this:

- Prints a report pertaining to that record
- Sets a boolean field to true
- Saves record using this line of code:
If Me.Dirty Then RunCommand acCmdSaveRecord
- prints same report again (form will show "Copy").

Works perferctly, never any problem.

One of my users just installed a new printer (HP laserjet P2055DN) and now the saverecord mysteriously fails, without an error message!

After changing the printer driver to one for a slightly older model, everything is back to normal again.

What the &$^&# is going on here?
Regards,

Jan Karel Pieterse
Excel MVP jkp-ads.com

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Printer driver prevents record save

Post by HansV »

Strange! The report did get printed twice with the newer printer driver?
Best wishes,
Hans

User avatar
Jan Karel Pieterse
Microsoft MVP
Posts: 656
Joined: 24 Jan 2010, 17:51
Status: Microsoft MVP
Location: Weert, The Netherlands

Re: Printer driver prevents record save

Post by Jan Karel Pieterse »

Odd thing is, the field DOES get updated, but the form's Dirty property stays true after the record save (which is when I throw the error). The relevant code is:

Code: Select all

                If Me.Dirty Then
                    DoCmd.RunCommand acCmdSaveRecord
                End If
                If Me.Dirty Then
                    'Record changes have not been saved!
                    MsgBox "Wijzigingen in record niet opgeslagen; afdrukken geannuleerd!", vbExclamation + vbOKOnly, "Wijzigingen niet opgeslagen"
                    Exit For
                Else
' other code goes here, e.g. print the form
Regards,

Jan Karel Pieterse
Excel MVP jkp-ads.com

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Printer driver prevents record save

Post by HansV »

It's hard to see how a printer driver could affect this!

Is an error handler active when this code is executed, or do you happen to have

On Error Resume Next

above this code?
Best wishes,
Hans

Mark L
3StarLounger
Posts: 331
Joined: 11 Feb 2010, 03:55
Location: Land O Lakes, FL

Re: Printer driver prevents record save

Post by Mark L »

My first question is "Why would you first print the report WITHOUT saving the record?". It seems to me the order of your code should be:

- Save record (if dirty)
- Print report
- set flag
- Print report

And I agree with Hans, I don't see how the Printer Driver could affect this.
Mark Liquorman
Land O Lakes, FL
see my website http://www.liquorman.net for Access Tips and Tricks, and for my Liquorman Utilities.