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

Record and Print

P: n/a
DD
The following code sits behind a clickEvent
my problem is two fold
1. I need to only allow the user to click the button once
2. I have used ClearForm() however this then stops the user from being
able to view and print an invoice.

any ideas on how i can get around this problem

Code
Set rs = db.OpenRecordset("tblInvoices")
With rs
.AddNew
!InvoiceDate = Now
theInvoice = !InvID
.Update
.Close
End With
DoCmd.RunCommand acCmdSaveRecord
Set rs = db.OpenRecordset("select * from tblOrderDetail where
[orderID]=" & [OrderID])
rs.MoveFirst
While Not rs.EOF
rs.Edit
rs!InvoiceID = theInvoice
rs.Update
rs.MoveNext

Wend

DoCmd.OpenReport "rptInvoice", acViewPreview, , "[OrderID]=" &
Me![OrderID]
'Yes No to print
OK = MsgBox("Do you want to print", vbYesNo, "Ready to print")
If OK = vbYes Then DoCmd.PrintOut , 0, 1

End If
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
DD wrote:
The following code sits behind a clickEvent
my problem is two fold
1. I need to only allow the user to click the button once
It appears it should work. You may want to do a
Docmd.SelectObject acReport,"YourReportName"
prior to the PrintOut

PrintOut requires the report to be the active object.
2. I have used ClearForm() however this then stops the user from being
able to view and print an invoice.
I use A97 so don't know about clearform().

BTW, you have an extra endif is I'm not mistaken at the end of your
code....otherwise it is superfluous.

BTW, consider updating the tblOrderDetail with an Update query.


any ideas on how i can get around this problem

Code
Set rs = db.OpenRecordset("tblInvoices")
With rs
.AddNew
!InvoiceDate = Now
theInvoice = !InvID
.Update
.Close
End With
DoCmd.RunCommand acCmdSaveRecord
Set rs = db.OpenRecordset("select * from tblOrderDetail where
[orderID]=" & [OrderID])
rs.MoveFirst
While Not rs.EOF
rs.Edit
rs!InvoiceID = theInvoice
rs.Update
rs.MoveNext

Wend

DoCmd.OpenReport "rptInvoice", acViewPreview, , "[OrderID]=" &
Me![OrderID]
'Yes No to print
OK = MsgBox("Do you want to print", vbYesNo, "Ready to print")
If OK = vbYes Then DoCmd.PrintOut , 0, 1

End If


Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.