Print current record and Invoice (report) if a textbox is checked. (1 Viewer)

T. McConnell

Registered User.
Local time
Today, 00:36
Joined
Jun 21, 2019
Messages
63
Hey all,
If this is posted somewhere already then my apologies, if you could point me to that thread then that'd be great as well. If not then if anyone could give some suggestions I'd appreciate it.
What I am wanting to do is I have an order form for doing a work order. I finally got everything to work, and has a submit order button (which currently using a macro to submit and refresh/reopen the order form) I can also switch to VB if better/easier. What has been asked is on the submit form button it looks to see if "Invoice requested" checkbox has been checked, if so it will automatically print an invoice (report called simply Invoice) with the current records information formatted/filteted by query using the JobID PK. At the same time though on submitting the form it also will print the current record displayed.
Current setup for the form and report will use the current records JobID field to print off everything. Basically in addition to submitting the form be able to print both a report and the form of current record.
I could even create just one button to print invoice, (If the customer decides they want a copy) then have the main submit form button be the one that prints the current record off. Any ideas or suggestions I truly would appreciate it.
Thank you in advance!
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:36
Joined
Oct 29, 2018
Messages
21,454
Hi. Not sure which part you need help with but to filter the report to the current record, you could use the WhereCondition argument of the OpenReport method. For example:
Code:
DoCmd.OpenReport "Invoice", acViewPreview, , "JobID=" & Me.JobID
Hope it helps...
 

T. McConnell

Registered User.
Local time
Today, 00:36
Joined
Jun 21, 2019
Messages
63
theDBguy,
Thanks for that info, I think to make some things easier, mostly for me haha, I'll just have one button for the user to click to print an invoice if requested by the customer.
The other piece I'm needing help with is the other button that submits the order. (named btnSubmit) When clicked I would like it to submit the order, (mainly saving the record and refreshing the form to a new record) and at the same time print the current record to fit on one page.
Would it be best to create another report with the order information I want and have the submit button call the report to print when submitting the form?
Is there any function that will automatically print the reports without opening the print dialog?
Thanks again.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:36
Joined
Oct 29, 2018
Messages
21,454
theDBguy,
Thanks for that info, I think to make some things easier, mostly for me haha, I'll just have one button for the user to click to print an invoice if requested by the customer.
The other piece I'm needing help with is the other button that submits the order. (named btnSubmit) When clicked I would like it to submit the order, (mainly saving the record and refreshing the form to a new record) and at the same time print the current record to fit on one page.
Would it be best to create another report with the order information I want and have the submit button call the report to print when submitting the form?
Is there any function that will automatically print the reports without opening the print dialog?
Thanks again.
Hi. You will hear many Access developers say, including me, that forms are for screens and reports are for papers. So, yes, I recommend creating a report to print rather than trying to print the form and worry about whether it fits one page or not. As for sending the report directly to the printer, you simply remove the acViewPreview argument. For example:
Code:
DoCmd.OpenReport "ReportName", , , "PK=" & Me.PK
 

T. McConnell

Registered User.
Local time
Today, 00:36
Joined
Jun 21, 2019
Messages
63
Awesome, thanks for the info. I will test that out and see if I did it right 😊
Thanks!
 

T. McConnell

Registered User.
Local time
Today, 00:36
Joined
Jun 21, 2019
Messages
63
Greetings,
I have tried using the following command, but when the reports loads it doesn't show the current record I am, the report is all blank. Any suggestions?

DoCmd.OpenReport "Invoice" , , , "JobID=" & Me.JobID

Thanks
 

June7

AWF VIP
Local time
Yesterday, 20:36
Joined
Mar 9, 2014
Messages
5,465
Is JobID a number type?

If you want to provide db for analysis, follow instructions at bottom of my post.
 

T. McConnell

Registered User.
Local time
Today, 00:36
Joined
Jun 21, 2019
Messages
63
Yes the JobID is a Number field, It is the Primary Key for the main table Jobs where this information is pulled from. I will try and get a decent copy of my database cleaned up and uploaded, may take me a little to get it uploaded. Until then I do have another question though, as I am creating a report, if I add a query for a second subform, if there is nothing entered as far as data wise, the whole report is blank. It works fine before adding the subquery to the report source.
 

June7

AWF VIP
Local time
Yesterday, 20:36
Joined
Mar 9, 2014
Messages
5,465
You stated 'second subform' - did you mean subreport? Then you say 'adding subquery to the report source'?

Will look at that as well when db provided.

Identify objects names involved.
 

T. McConnell

Registered User.
Local time
Today, 00:36
Joined
Jun 21, 2019
Messages
63
So I finally got my report to have all the correct information, however when trying to still use the code below, it won't pull up the current record I am on, just a blank report. I have tried different ways of getting this to pull up the current record in a report. I know you ask for the database, sorry I am having some trouble getting it to upload right now.
All I need to do is get the submit button to do the following.
1.) Save the record and go to a new record with a blank form
2.) Open a report with the current record for printing

DoCmd.OpenReport "rptOrdersQry", acViewPreview, , "[JobID]=" & Me.JobID

Thanks again for your help!
 

June7

AWF VIP
Local time
Yesterday, 20:36
Joined
Mar 9, 2014
Messages
5,465
If you open report after moving to new blank record then that could be why report is blank. Post your code from button click event.
 

T. McConnell

Registered User.
Local time
Today, 00:36
Joined
Jun 21, 2019
Messages
63
I believe I have got it working actually, I just put two separate buttons one to print the invoice for the customer, then one to print the order both pointing to records. I was having issues trying to get some of the data to display from my queries to the report (if they were blank as if nothing was entered) I was able to get this information to populate by creating sub reports with the main report, the sub reports displayed their own query pointing the data I needed. Not sure if this is a great way of doing that, but so far it seems to be working....Knock on wood haha.
Thanks again for all of the help everyone. I am sure I will run into other issues, but hopefully nothing I can't find resources for on here.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:36
Joined
Oct 29, 2018
Messages
21,454
Congratulations! Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom