473,320 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Record and Print

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
1 1373
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: les_ander | last post by:
Hi, I know that i can do readline() from a file object. However, how can I read till a specific seperator? for exmple, if my files are name profession id #
1
by: SAN CAZIANO | last post by:
I have to insert a button in the left of all record in a table to print the current record, simply create a table and print it in the printer. anyone have an idea or there is a printer/report...
8
by: mark | last post by:
Access2000 How do I write a query that combines the CTC field from each record below into one record? I need to concatenate the CTC field with a separator, like below: ...
2
by: Paul Mendez | last post by:
I have a form that consists of 150 records and is still growing. there are times when I want to print a certain record of the form, say record 12. I go to file --> print and choose the page number...
2
by: NomoreSpam4Me | last post by:
Hi, i have a little problem: I have a form where people enter data and when they click on the save button it saves the data then open 2 field for my criterias and then open a rpt with that. But...
1
by: kkrizl | last post by:
I have a form that displays general information about an alarm permit location. There's a subform that shows detailed information about burglar alarms that have gone off at the location. When a...
5
by: John | last post by:
Hi If I have a form open, what is the code that is equivalent to using the File->Print menu with select record(s) option to print the form with the currently displayed record values? Thanks ...
16
by: google | last post by:
In a continuous form the following code is under a button in the form header. In Access 2003 and earlier, this goes to a new record, then adds relevant data to that new record. DoCmd.GoToRecord...
5
by: bob44 | last post by:
Hi, I recently created a mysql database using phpmyadmin. I then proceeded to make a form to insert data into the database, but the problem is that the form is only able to insert one record, and...
0
by: emalcolm_FLA | last post by:
Hello and TIA for any help with this non profit Christmas assistance project. I have an applicant (app history) and child (child history) tables (4 total). I need to grab the next available (in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.