DoCmd.OpenReport error 2501

T

Tony Girgenti

Hello.

Using Access 2002 on Windows XP Pro, SP2 computer.

When running the code at the end of this post, it blows up on the
DoCmd.OpenReport with error 2501.

I can't figure out why. I tried searching for that error with no luck.

This problem only occurs on one computer. The same program works for
everyone else on the LAN. It is being run from a network drive.

Any help would be gratefully appreciated.

Thanks,
Tony

If strWhere = " " Then
DoCmd.OpenReport stDocName, acViewPreview
Else
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
End If

Exit_Command2_Click:
Exit Sub

Err_Command2_Click:

If Err.Number <> 2501 Then
MsgBox Err.DESCRIPTION
End If

On Error GoTo 0

Resume Exit_Command2_Click

End Sub
 
C

Carl Rapson

Tony Girgenti said:
Hello.

Using Access 2002 on Windows XP Pro, SP2 computer.

When running the code at the end of this post, it blows up on the
DoCmd.OpenReport with error 2501.

I can't figure out why. I tried searching for that error with no luck.

This problem only occurs on one computer. The same program works for
everyone else on the LAN. It is being run from a network drive.

Any help would be gratefully appreciated.

Thanks,
Tony

If strWhere = " " Then
DoCmd.OpenReport stDocName, acViewPreview
Else
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
End If

Exit_Command2_Click:
Exit Sub

Err_Command2_Click:

If Err.Number <> 2501 Then
MsgBox Err.DESCRIPTION
End If

On Error GoTo 0

Resume Exit_Command2_Click

End Sub

One common cause of reports not working for a single user is that the user
doesn't have a default printer defined for Windows. You can check that, and
you can also try setting a different printer as the default printer.

Carl Rapson
 
T

Tony Girgenti

Hello Carl.

Thanks for your help with this. Sure enough, that was the problem.

This one workstation is the only one that has a barcode printer attached to
it and the barcode printer was set as the default. As soon as we changed
the default printer to a laser printer, it allowed this workstation to view
the Access reports.

Do you have any idea of how to handle this problem if they want to leave the
default as the barcode printer? I mean how can we make it so that the
default printer is set to the laser when they go to the Access reports? I
know we can do it manually before going to Access.

Any help would be gratefully appreciated.

Thanks,
Tony
 
C

Carl Rapson

Unfortunately, I can't help you much there. I haven't encountered that
situation, so I don't know what the prodecure would be to change the default
printer in code. If you search this newsgroup for Printer you might find
some examples that will put you on track.

One thing I would suggest is to check the default printer at startup and
prompt the user to change it. You may have to have them change it manually,
but it should be possible to at least see what the default is. Look into the
Application.Printers collection.

Carl Rapson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top