473,378 Members | 1,621 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,378 software developers and data experts.

Print reports after specified number of command button clicks

I have created a Access production database that records good parts and bad parts to a table thru querys using macros and command buttons on a form. A report (part label) is printed each time a command button is clicked for good or bad parts. When the container is filled with good parts, the operator manualy clicks a command button to print a report (container label). I have been asked to automate the container label report so it prints when the correct number of good part command button clicks have been performed. I think this can be done using a module to keep track of the number of operations of the good part command button, print the report and reset the count, but I do not have any knowledge of VB. The correct number of parts value will be selected from a table 'tbl_partkbqty' that contains the part number - 'PartNo' - column and quantity - 'Mulqty_01' - column. Can anyone give me instruction on how this can be accomplished? Is it is possible to perform this operation using standard Access macros or will VB be necessary?
Oct 1 '07 #1
9 3056
Scott Price
1,384 Expert 1GB
You have posted your question in the Access Articles section rather than the Access Forum section.
I have moved it across for you.

MODERATOR.
Oct 1 '07 #2
ADezii
8,834 Expert 8TB
I have created a Access production database that records good parts and bad parts to a table thru querys using macros and command buttons on a form. A report (part label) is printed each time a command button is clicked for good or bad parts. When the container is filled with good parts, the operator manualy clicks a command button to print a report (container label). I have been asked to automate the container label report so it prints when the correct number of good part command button clicks have been performed. I think this can be done using a module to keep track of the number of operations of the good part command button, print the report and reset the count, but I do not have any knowledge of VB. The correct number of parts value will be selected from a table 'tbl_partkbqty' that contains the part number - 'PartNo' - column and quantity - 'Mulqty_01' - column. Can anyone give me instruction on how this can be accomplished? Is it is possible to perform this operation using standard Access macros or will VB be necessary?
  1. Declare a Public Variable in a Standard Code Module to hold the number of Clicks.
    Expand|Select|Wrap|Line Numbers
    1. Public intTimesClicked As Integer
  2. In the Click() Event of a Command Button, place the following code:
    Expand|Select|Wrap|Line Numbers
    1. Dim intRequiredClicks As Integer
    2.  
    3. intTimesClicked = intTimesClicked + 1
    4.  
    5. 'Assuming a Field on your Form contains the PartNo and is called txtPartNo, and it is Numeric
    6. intRequiredClicks = DLookup("[Mulqty_01]", "tbl_partkbqty", "[PartNo] =" & Me![txtPartNo])
    7.  
    8. 'Assuming a Field on your Form contains the PartNo and is called txtPartNo, and it is a String
    9. intRequiredClicks = DLookup("[Mulqty_01]", "tbl_partkbqty", "[PartNo] ='" & Me![txtPartNo] & "'")
    10.  
    11. If intRequiredClicks = intTimesClicked Then
    12.   DoCmd.OpenReport "rptWhatever", acViewNormal
    13.     intTimesClicked = 0     'Reset the old clicker
    14. End If
  3. Since the Variable is Public, you'll need an Option to Reset it in some Event (Current(), Click(), etc.). Idf you don't Reset it, it will maintain its value from Record to Record.
    Expand|Select|Wrap|Line Numbers
    1. intTimesClicked = 0
Oct 2 '07 #3
Thanks a bunch, this really helps. One problem however, the Click() event of the command button that is to be counted already runs a macro called Good++, which, among other things prints the report "part label". Can I create a module with the vb code you supplied in lines 1,3, 9, 11, 12, 13 and 14; name the module, add the RunCode action to the macro and call the named module as the Function argument?
Also, it appears the comand to print the report will only display the report. I need it to print directly to the printer without viewing, or am I making an assumption because of my lack of vb knowledge?
Thanks Again,
Larryimic
Oct 2 '07 #4
Thanks a bunch, this really helps. One problem however, the Click() event of the command button that is to be counted already runs a macro called Good++, which, among other things prints the report "part label". Can I create a module with the vb code you supplied in lines 1,3, 9, 11, 12, 13 and 14; name the module, add the RunCode action to the macro and call the named module as the Function argument?
Also, it appears the comand to print the report will only display the report. I need it to print directly to the printer without viewing, or am I making an assumption because of my lack of vb knowledge?
Thanks Again,
Larryimic
Another option that I have used in the past when I don't feel like playing with public variables is that you can insert a textbox into your form and make it's visible setting set to false. Then, every time you click the button just increase the value of the textbox by one.

If you want to separate your macros, you could set the print macro to run off of the textbox_AfterUpdate event, that way you could keep your current button macro (just add the +1 to the textbox step).
Oct 2 '07 #5
ADezii
8,834 Expert 8TB
Thanks a bunch, this really helps. One problem however, the Click() event of the command button that is to be counted already runs a macro called Good++, which, among other things prints the report "part label". Can I create a module with the vb code you supplied in lines 1,3, 9, 11, 12, 13 and 14; name the module, add the RunCode action to the macro and call the named module as the Function argument?
Also, it appears the comand to print the report will only display the report. I need it to print directly to the printer without viewing, or am I making an assumption because of my lack of vb knowledge?
Thanks Again,
Larryimic
Why not execute the code directly that prints the Report, then run the Good++ Macro eliminating the reference to OpenReport? The acViewNormal Parameter should Print the report directly.
Oct 2 '07 #6
Sorry for taking so long to get back. This was a great idea, thank you so much. I Took the code you provided, added the code from the macro and in the Click() event of the command button choose code builder, typed in the two codes as one event and it works like a charm. This site is great, I just wish I had known about it years ago. Again, thank you for all your help.
Oct 9 '07 #7
ADezii
8,834 Expert 8TB
Sorry for taking so long to get back. This was a great idea, thank you so much. I Took the code you provided, added the code from the macro and in the Click() event of the command button choose code builder, typed in the two codes as one event and it works like a charm. This site is great, I just wish I had known about it years ago. Again, thank you for all your help.
We are always glad to help.
Oct 9 '07 #8
Peader
19
Hello ADezii

I've a very similar problem to Larryimic's. I'm trying to print a report after a specific number (10) of command button clicks and also I'm very new to this. I understand the principle behind the program you describe however can you help me understand the specific function (and difference) of the lines 6 & 9.

Thanks for any advise you could provide,
Peader

  1. Declare a Public Variable in a Standard Code Module to hold the number of Clicks.
    Expand|Select|Wrap|Line Numbers
    1. Public intTimesClicked As Integer
  2. In the Click() Event of a Command Button, place the following code:
    Expand|Select|Wrap|Line Numbers
    1. Dim intRequiredClicks As Integer
    2.  
    3. intTimesClicked = intTimesClicked + 1
    4.  
    5. 'Assuming a Field on your Form contains the PartNo and is called txtPartNo, and it is Numeric
    6. intRequiredClicks = DLookup("[Mulqty_01]", "tbl_partkbqty", "[PartNo] =" & Me![txtPartNo])
    7.  
    8. 'Assuming a Field on your Form contains the PartNo and is called txtPartNo, and it is a String
    9. intRequiredClicks = DLookup("[Mulqty_01]", "tbl_partkbqty", "[PartNo] ='" & Me![txtPartNo] & "'")
    10.  
    11. If intRequiredClicks = intTimesClicked Then
    12.   DoCmd.OpenReport "rptWhatever", acViewNormal
    13.     intTimesClicked = 0     'Reset the old clicker
    14. End If
  3. Since the Variable is Public, you'll need an Option to Reset it in some Event (Current(), Click(), etc.). Idf you don't Reset it, it will maintain its value from Record to Record.
    Expand|Select|Wrap|Line Numbers
    1. intTimesClicked = 0
Oct 15 '07 #9
Scott Price
1,384 Expert 1GB
Peader,

You have asked your question in another member's thread. This is called thread hijacking and is not allowed on this site. There are various reasons for this, the principal of which is that it typically diverts the flow of the thread away from his needs and into yours. Another is that it will tend to mean that your new question is not seen as such, and may get overlooked by many of our experts (You appreciate that they're not looking for answered questions).
Please post your questions in their own threads in future (See POSTING GUIDELINES ).

Especially pay attention to this section about How to ask a question , as you will need to reword your question to indicate exactly what you have tried, and what is not working for you.

MODERATOR.
Oct 15 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ian | last post by:
(Sorry if I have repeated this, it did not appear the first time) I have the following code on a button. The idea is that when this button is clicked it prints several reports automatically then...
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: Rosy | last post by:
I am attempting to use the following code to print a report based on the current record in the form. Users bring up the record with a parameter box and then can make changes to the sub-form on the...
22
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the...
2
by: Kil | last post by:
I designed a form that allows the user to enter dates, and click a checkbox so that certain forms may be loaded. However, I have had trouble getting the right information to load. I would like to...
0
by: John Smith | last post by:
Hello, I am developing a VB.NET 2003 application that will use lots of Crystal Reports. Sometimes the users will preview a report in a Crystal report viewer, and sometimes they will send the...
1
by: kirkus84 | last post by:
I am currently trying to do a multiple record mail merge through a query via a command button on a form. The query basically displays customers who have said yes to privacy. The user inputs a date...
0
by: EricJudge06 | last post by:
We are converting some reports from Crystal Reports to Microsoft SQL Reporting Services (SSRS) in an ASP 2.0 VB.Net web app. Crystal had a function called PrintToPrinter which was being used to...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.