473,769 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looping through Combo Box to Print Reports

31 New Member
I have a report that opens based on the where the office code on the form matches the office code on the report. that works fine.

I have written code that sets the combo box value opens the report (acnormal), then closes report, then sets the combo box value again, opens the report and then close the report.....on and on.

The combo box grows monthly and instead of having to keep updated the code with new office codes, I would like the database to loop through each value of the combo box, print the repot, and then go on to the next one.

Here is the code I am using.
Expand|Select|Wrap|Line Numbers
  1. Dim val As Variant
  2. For Each val In Me.ctrlBranchCode
  3.  
  4. DoCmd.OpenReport "rptBranchProductionWeekMtdYtd", acNormal, , "[Branch Code] = Forms!frmWeeklyMonthlyReporting!ctrlBranchCode"
  5. DoCmd.Close acReport, "rptBranchProductionWeekMtdYtd"
I am gettting an error that says "Object does not support this property or method".

Any help would be greatly appreciated.

A
May 20 '09 #1
9 10228
ADezii
8,834 Recognized Expert Expert
@apank
Here is code that will allow you to return the data in the 'Bound' Column of a Combo Box for each specified Row:
Expand|Select|Wrap|Line Numbers
  1. Dim intCounter As Integer
  2. Dim cboCode As ComboBox
  3.  
  4. Set cboCode = Me![ctrlBranchCode]
  5.  
  6. For intCounter = 0 To cboCode.ListCount - 1
  7.   Debug.Print cboCode.ItemData(intCounter)
  8. Next
May 21 '09 #2
apank
31 New Member
@ADezii

The procedure you described worked but I cannot get it to update the combo box, then print the report based on the combo, then close the report and print the next one. I am sure the answer is close but I can't seem to find it.

As always your help is much appreciated.

A
May 21 '09 #3
ADezii
8,834 Recognized Expert Expert
@apank
  1. How are you Updating the Combo Box?
  2. At what specific point are you Updating the Combo Box?
May 21 '09 #4
apank
31 New Member
@ADezii
The combo box has a list. I would like the procedure to go through the list, choose each office code listed and print the report(The report prints based WHERE office code = the combo box). I can do it if I hard code the office codes in the procedure and do a set value, but would like it to loop through the combo box instead. That way if new offices are added the report will print automatically.

Thanks
May 22 '09 #5
ADezii
8,834 Recognized Expert Expert
@apank
If the Row Source for the Combo Box is created correctly, what you request 'will' be done automatically.
May 22 '09 #6
apank
31 New Member
The series of events should go as follows.
1) Have the report print based on the first branch code in the combo box
2) Close the report
3) Change the branch code in the combo box to the next branch code
4) Print the Report
5) Repeat until the report has been printed for all the branch codes listed.
May 22 '09 #7
ADezii
8,834 Recognized Expert Expert
@apank
Try:
Expand|Select|Wrap|Line Numbers
  1. Dim intCounter As Integer
  2. Dim cboCode As ComboBox
  3.  
  4. Set cboCode = Me![ctrlBranchCode]
  5.  
  6. 'If [Branch Code] is Numeric
  7. For intCounter = 0 To cboCode.ListCount - 1
  8.   DoCmd.OpenReport "rptBranchProductionWeekMtdYtd", acNormal, , _
  9.                    "[Branch Code] = " & cboCode.ItemData(intCounter)
  10.   DoCmd.Close acReport, "rptBranchProductionWeekMtdYtd"
  11. Next
  12.  
  13. 'If [Branch Code] is a String
  14. For intCounter = 0 To cboCode.ListCount - 1
  15.   DoCmd.OpenReport "rptBranchProductionWeekMtdYtd", acNormal, , _
  16.                    "[Branch Code] = '" & cboCode.ItemData(intCounter) & "'"
  17.   DoCmd.Close acReport, "rptBranchProductionWeekMtdYtd"
  18. Next
May 22 '09 #8
apank
31 New Member
Thank you very much for this Adezzi. Worked great.
Jun 2 '09 #9
ADezii
8,834 Recognized Expert Expert
@apank
You are quite welcome, apank.
Jun 2 '09 #10

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

Similar topics

0
1099
by: Peter | last post by:
My client has retail shops. All these shops will access retail application through Internet. So sales receipts will be generated from web/application server and send across Internet to shops. Crystal Report is web enable and would be a solution. So far I have seen Crystal Report report displays on the browser and on the browser, user has to press a print button to print the report. Does anyone have experience printing sales receipts,...
0
3262
by: banderas | last post by:
Just wondering if it is possible to use access to create grpahs and even print reports? Is it possible to link excell with access so one can be the date base and when graphs and analytical reports are needed, I can call excell?
2
1657
by: Access Guy | last post by:
I have a procedure to automate .pdf reports. I set the default printer to the pdfwriter driver before running. When the procedure runs, some of the reports get an error: "Cannot print, the file is in use or locked". Any ideas? Win2k and Access v8.
0
2266
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 loops through several other reports and prints them. These reports are not sent to a printer but sent to a program called Fine Print PDF Factory which turns them into a PDF file (set as the default printer) This all works perfectly unless any...
6
3370
by: Julian | last post by:
Hi, I am a very beginner in databases. I created a database table in Access 2003 and OOo 2.03 that includes name, address, postcode, phone numbers etc of our customers. I would like to sort customers by areas of London, UK by the first part of the postcode. The London postcodes are the form of E19 4PR, NW5U 4RT. So I would like to print a report (customers arranged into Word tables - normal tables, not database tables) for example which...
2
2182
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 enable certain reports to be displayed as the user checks the box and the clicks the cmdReport button. Also, is there a certain way to combine reports, loaded separately, to load into one for printing (e.g. report1 and report2 are checked, how...
2
1636
by: Ez | last post by:
I have a MS access database that runs on the network. Few pcs access the database simulataneously every day. The users run a lot of reports from the Access database and print outs always looked good. Now there is a new pc thats been added with the same OS. Its even the same brand Dell pc. But the print out command given from the new pc, makes the reports look like gibberish with a new font, unwanted spaces every where etc...
0
1795
AllusiveKitten
by: AllusiveKitten | last post by:
Hi kind and helpful people... At work I am creating a database and reports that will be used by multiple people. What I need is for my reports to print to a specific colour printer and be manual feed as the papersize is different. The following coding does select the printer that I require on my computer, but as different people have different printers loaded to their machines the number of printers and the orders vary, so my coding falls...
2
2028
by: JM420A | last post by:
I have 3 reports that I need to print sequentially, situation is this R- Report P-Person R1 has 3 pages, one for each P R2 " " R3 " " I would like to be able to print R1P1,R2P1,R3P1..., then do the same thing for each subsequent person.
0
9422
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9857
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.