Record and Print

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Hi DD:

Seems to me that the best way to allow only one click is what is done on
say, the Paypal site-> just make the clickbutton's "enabled" property set to
FALSE:

MyNextObject.Setfocus
MyClickbutton.enabled = False

Regards,
Al

DD said:
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
 
Back
Top