Go Back   Access World Forums > Microsoft Access Discussion > Reports

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-21-2019, 05:20 AM   #1
T. McConnell
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
T. McConnell is on a distinguished road
Print current record and Invoice (report) if a textbox is checked.

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!

T. McConnell is offline   Reply With Quote
Old 06-21-2019, 06:39 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 3,063
Thanks: 36
Thanked 729 Times in 712 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Print current record and Invoice (report) if a textbox is checked.

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...
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 06-21-2019, 08:00 AM   #3
T. McConnell
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
T. McConnell is on a distinguished road
Re: Print current record and Invoice (report) if a textbox is checked.

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.

T. McConnell is offline   Reply With Quote
Old 06-21-2019, 08:16 AM   #4
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 3,063
Thanks: 36
Thanked 729 Times in 712 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Print current record and Invoice (report) if a textbox is checked.

Quote:
Originally Posted by T. McConnell View Post
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
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
T. McConnell (06-21-2019)
Old 06-21-2019, 08:27 AM   #5
T. McConnell
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
T. McConnell is on a distinguished road
Re: Print current record and Invoice (report) if a textbox is checked.

Awesome, thanks for the info. I will test that out and see if I did it right 😊
Thanks!
T. McConnell is offline   Reply With Quote
Old 06-21-2019, 08:33 AM   #6
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 3,063
Thanks: 36
Thanked 729 Times in 712 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Print current record and Invoice (report) if a textbox is checked.

Quote:
Originally Posted by T. McConnell View Post
Awesome, thanks for the info. I will test that out and see if I did it right 😊
Thanks!
You're welcome. Good luck!
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 06-22-2019, 06:16 PM   #7
T. McConnell
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
T. McConnell is on a distinguished road
Re: Print current record and Invoice (report) if a textbox is checked.

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

T. McConnell is offline   Reply With Quote
Old 06-22-2019, 06:19 PM   #8
June7
Newly Registered User
 
June7's Avatar
 
Join Date: Mar 2014
Posts: 1,959
Thanks: 0
Thanked 463 Times in 459 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Print current record and Invoice (report) if a textbox is checked.

Is JobID a number type?

If you want to provide db for analysis, follow instructions at bottom of my post.
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is offline   Reply With Quote
Old 06-22-2019, 08:10 PM   #9
T. McConnell
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
T. McConnell is on a distinguished road
Re: Print current record and Invoice (report) if a textbox is checked.

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.
T. McConnell is offline   Reply With Quote
Old 06-22-2019, 08:16 PM   #10
June7
Newly Registered User
 
June7's Avatar
 
Join Date: Mar 2014
Posts: 1,959
Thanks: 0
Thanked 463 Times in 459 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Print current record and Invoice (report) if a textbox is checked.

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.
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is offline   Reply With Quote
Old 06-23-2019, 12:45 AM   #11
T. McConnell
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
T. McConnell is on a distinguished road
Re: Print current record and Invoice (report) if a textbox is checked.

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!
T. McConnell is offline   Reply With Quote
Old 06-23-2019, 09:52 AM   #12
June7
Newly Registered User
 
June7's Avatar
 
Join Date: Mar 2014
Posts: 1,959
Thanks: 0
Thanked 463 Times in 459 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Print current record and Invoice (report) if a textbox is checked.

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.
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is offline   Reply With Quote
Old 06-23-2019, 03:41 PM   #13
T. McConnell
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
T. McConnell is on a distinguished road
Re: Print current record and Invoice (report) if a textbox is checked.

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.
T. McConnell is offline   Reply With Quote
Old 06-24-2019, 07:10 AM   #14
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 3,063
Thanks: 36
Thanked 729 Times in 712 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Print current record and Invoice (report) if a textbox is checked.

Congratulations! Glad to hear you got it sorted out. Good luck with your project.

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Print current record of a report dbaldwin Modules & VBA 6 11-24-2011 11:44 AM
have a report print from current record Maclain General 5 05-11-2011 06:07 AM
Print only report for current record jamphan General 1 08-20-2007 05:40 AM
Print Current Record to Report Ukraine82 Forms 3 05-23-2005 03:45 AM
Print Report from current record sweetcaro Reports 2 05-25-2001 05:28 PM




All times are GMT -8. The time now is 02:49 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World