G
Guest
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
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