469,297 Members | 2,141 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,297 developers. It's quick & easy.

Printing options from Command Button

114 100+
Hello,

I am using MS Access 2002-2003. I added a "Print Record" command button to a form in my database. Is there a way (via VBA or anything else) to open a print preview screen when the command button is selected instead of immediately printing the record?

Thank you!

Martin DH
Mar 6 '07 #1
5 7999
ADezii
8,800 Expert 8TB
Hello,

I am using MS Access 2002-2003. I added a "Print Record" command button to a form in my database. Is there a way (via VBA or anything else) to open a print preview screen when the command button is selected instead of immediately printing the record?

Thank you!

Martin DH
Print Preview was designed primarily as the View Argument to the OpenReport() Method. From my knowledge, it was not intened to be utilized for individual Record printing. The following code will, however, work but probably not with the intended result. It is simply out of context. Try it and see:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
  2. DoCmd.RunCommand acCmdPrintPreview
Mar 6 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
Assuming the current code is ...

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "Report Name", , , [WhereCondition]
Change it to ...
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "Report Name", acViewPreview, , [WhereCondition]
Mar 6 '07 #3
ADezii
8,800 Expert 8TB
Assuming the current code is ...

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "Report Name", , , [WhereCondition]
Change it to ...
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "Report Name", acViewPreview, , [WhereCondition]
Hello Mary:
I was under the assumption that the OP was printing a Record from Form View. Is my interpretation wrong?
Mar 6 '07 #4
MMcCarthy
14,534 Expert Mod 8TB
Hello Mary:
I was under the assumption that the OP was printing a Record from Form View. Is my interpretation wrong?
I wasn't sure from the question so offered the alternative solution. I'm sure we'll find out eventually.

Mary
Mar 6 '07 #5
martin DH
114 100+
I wasn't sure from the question so offered the alternative solution. I'm sure we'll find out eventually.

Mary

Yes, I am working in the form view. Below is the code from the print record command as is. The DoCmd.RunCommand acCmdPrintPreview code brings up a print preview of all the records, not just the selected record. I appreciate the help!

Expand|Select|Wrap|Line Numbers
  1. Private Sub Print_File_Click()
  2. On Error GoTo Err_Print_File_Click
  3.  
  4.     DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
  5.     DoCmd.PrintOut acSelection
  6.  
  7. Exit_Print_File_Click:
  8.     Exit Sub
  9.  
  10. Err_Print_File_Click:
  11.     MsgBox Err.Description
  12.     Resume Exit_Print_File_Click
  13.  
  14. End Sub
Mar 8 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Darcy Kahle | last post: by
4 posts views Thread by Marina Ferguson | last post: by
15 posts views Thread by TJ Walls | last post: by
9 posts views Thread by Tony Williams | last post: by
5 posts views Thread by Stefania Scott | last post: by
1 post views Thread by Dreamtime | last post: by
1 post views Thread by Stinky Pete | last post: by
3 posts views Thread by Richard MSL | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.