By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,482 Members | 2,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,482 IT Pros & Developers. It's quick & easy.

save/print/close

P: n/a
I have a form that creates a new ticket. Click save on the form and the form
closes and updates the form underneath. I would like to print a report from
this form when I hit the save button all at the same time.

Here is what I have been working with.

Private Sub btnAddNewMaint_Click()
Dim stDocName As String
Dim stReportName As String

stDocName = "frmCustomer"
stReportName = "rptMaintTicket"

MsgBox "Print a copy for tech to printer xxxxxxxx.", vbOKOnly, "Tech
Ticket"

DoCmd.OpenReport stReportName, acPreview
DoCmd.Close

DoCmd.OpenForm stDocName
'refresh
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

End Sub

This seems to flash the Preview screen but closes it. Also the form is left
open.
Can this be done in one action?

Gerald

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1

Dec 12 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Instead of DoCmd.Close be specific and write
DoCmd.Close acForm, "NameOfForm"

Dec 12 '06 #2

P: n/a
The reason it keeps showing a preview is because your code for
DoCmd.OpenReport has acPreview at the end. I don't remember the exact
option on it, but it will pop up when you go to change it.

Jason

gjameson via AccessMonster.com wrote:
I have a form that creates a new ticket. Click save on the form and the form
closes and updates the form underneath. I would like to print a report from
this form when I hit the save button all at the same time.

Here is what I have been working with.

Private Sub btnAddNewMaint_Click()
Dim stDocName As String
Dim stReportName As String

stDocName = "frmCustomer"
stReportName = "rptMaintTicket"

MsgBox "Print a copy for tech to printer xxxxxxxx.", vbOKOnly, "Tech
Ticket"

DoCmd.OpenReport stReportName, acPreview
DoCmd.Close

DoCmd.OpenForm stDocName
'refresh
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

End Sub

This seems to flash the Preview screen but closes it. Also the form is left
open.
Can this be done in one action?

Gerald

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1
Dec 13 '06 #3

P: n/a
I do want it to preview. Problem now is that the report does not have the
data entered that was just entered. I guess it has not been written to the db
yet, until it closes. Any other way of doing this?

Gerald

ja*********@gmail.com wrote:
>The reason it keeps showing a preview is because your code for
DoCmd.OpenReport has acPreview at the end. I don't remember the exact
option on it, but it will pop up when you go to change it.

Jason
>I have a form that creates a new ticket. Click save on the form and the form
closes and updates the form underneath. I would like to print a report from
[quoted text clipped - 30 lines]
>Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1

Dec 13 '06 #4

P: n/a
I guess this can not be done.

gjameson wrote:
>I do want it to preview. Problem now is that the report does not have the
data entered that was just entered. I guess it has not been written to the db
yet, until it closes. Any other way of doing this?

Gerald
>>The reason it keeps showing a preview is because your code for
DoCmd.OpenReport has acPreview at the end. I don't remember the exact
[quoted text clipped - 7 lines]
>>Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1
--
Message posted via http://www.accessmonster.com

Dec 14 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.