473,668 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print different reports based on field value?

7 New Member
Hi everyone! I really hope my problem will be a piece of cake for an expert coder :)

I have a table with 100 records, and I need to print them all between 10 different reports based on each record field value, all with a single click.

As you guessed, I dont know much about vb, so I would really appreciate some code to do what is required.

thanks!
Apr 4 '08 #1
4 4440
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. I am sure that there would be many contributors who could assist you once you tell us what it is you need to do. As it is we would just be guessing.

Do the ten different reports have the same recordsource? What is the relationship between the reports and the table with 100 records? On what basis do you select the reports to be printed? Have you a form with a selection combo or listbox for users to select particular reports?

These are just starter questions. To provide any form of solution we would need to know form names, control names, field names and relationships for relevant fields.

Please understand, what you ask is non-trivial and cannot be answered by guesswork...

-Stewart

Hi everyone! I really hope my problem will be a piece of cake for an expert coder :)

I have a table with 100 records, and I need to print them all between 10 different reports based on each record field value, all with a single click.

As you guessed, I dont know much about vb, so I would really appreciate some code to do what is required.

thanks!
Apr 5 '08 #2
kv29
7 New Member
Stewart, the table is quite simple, has 4 fields and the last one ("code") allows numbers from 1 to 10 (that represent those 10 different reports, also named "1" to "10"). no need for the user to fill the "code" field.

what I need is to print them all, each record on its own report, in a single print batch.
Apr 5 '08 #3
Stewart Ross
2,545 Recognized Expert Moderator Specialist
This is useful clarification - thank you. There are still details missing, however. What is the name of the table? What is the name of the field that makes each record in the 100 records unique?

From what you have told me so far, there are ten reports to be run. If I was being naive about it I would provide you with a simple loop in which a counter runs from 1 to 10, that opens each report in turn. However, such an approach has nothing whatsoever to do with the 100 records you mention:

Expand|Select|Wrap|Line Numbers
  1. Dim Counter as Integer
  2. For Counter = 1 to 10
  3.    DoCmd.OpenReport Str(Counter), acViewNormal
  4. Next Counter
I know from experience that is not what you need - but what you have told me does not actually help me to provide you with a full solution. The norm is to process the recordset contents in a different kind of loop like the one below. To print each record separately as you are requesting you need to filter the report for each unique record, but you have not said what field that is. A placeholder is shown below for the table name and for that unique field.

[code=vb]Dim RS as DAO.RecordSet
Dim ReportNo as String
Dim ReportFilter as String
Set RS = CurrentDB.OpenR ecordset("name of your 100 record table")
Do While Not RS.EOF
ReportNo = Str(RS!
Expand|Select|Wrap|Line Numbers
  1. )
  2.   ReportFilter = "[unique record ID] = " & RS![unique record ID]
  3.   DoCmd.OpenReport ReportNo, acViewNormal, , ReportFilter
  4.   RS.Movenext
  5. Loop
  6. RS.Close
The skeleton above is incomplete because, as I have said, the missing details are not things I can guess at. The code above assumes that the unique ID is some form of number. If it is a string value change the filter line to
Expand|Select|Wrap|Line Numbers
  1. ReportFilter = "[unique record ID] = '" & RS![unique record ID] & "'"
Add the code above to the On Click event of a control you place on a form somewhere. You may also need to add a reference to the DAO Object library - from the VB editor choose Tools, References and tick the MS DAO 3.x object library if it is not already ticked.

I am sure that once you fill in the missing details that I cannot you will be able to resolve any remaining issues reasonably easily yourself.

-Stewart
Apr 6 '08 #4
kv29
7 New Member
Stewart, your code works like a charm!
Every report is to be sent to a printed form, so they are supposed to fill "empty fields". Do you suggest to put some kind of pause in between not to screw the printing order?

btw, I was thinking to change the "code" field (and so all the reports) from numbers to text, do I need to change something on your code?

thanks!!
Apr 8 '08 #5

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

Similar topics

7
1676
by: Jonathan Smith | last post by:
Hi In order to make it easier for my colleagues to write their school reports I thought I might attempt to write a (simple) program. At the moment I am working mentally through the steps I would have to code just to make sure that I can do everything before I start. I have come to a halt with regard to printing them out. Any software I produce would have to produce a report in the same format as the one we curently use (they are hand...
3
3850
by: gasturbtec | last post by:
i'm using access 2000 and have a form in which users can select reports with check boxes and click a print button to print out the selected reports. what i want to do now is place a text box on the form where the user can put the number of copies they want to print. i want to take that value and loop through my print code the number of time = to the text box value
8
3950
by: Hank Reed | last post by:
Hello, I have searched through dozens of old responses to this question but have been unable to make it work in my situation. I'm using Access 2000 We have a very old sticker printer on a serial line. Neither situation is going to be upgraded so don't suggest that. A simple sticker report takes 10 seconds to reach the printer. That is not an issue for me. But, if I want 5 copies of the same sticker, most methods I have tried...
2
1782
by: Claudia Fong | last post by:
Hi, I have 4 reports created in Ms-access and I will use VB to print those reports. My problem is I'm not sure if I can control wich report to print.. Those reports are almost the same, what is different is the logo in the report header or page header. Because there are 4 different logo. I want the user to choose in VB which logo to use and then VB will print the report that the user chose.
3
10051
by: Noelene | last post by:
Hi, I'm desperate. I've been trawling through this and other forums but still can't work out what to do. I've seen similar questions but my lack of code knowledge has stopped me working this out myself. I have a report to update clients on the status of work we are doing for them. I need to automatically create individual reports for each client showing updates from the previous month. The report is called: rMRClient The query it is...
4
13677
by: sara | last post by:
Hi - I've looked at many posts, and cannot find the answer on this specific problem. I have several fields on a table, which I've defined as "Text", 3 characters, Format Yes/No (I picked up the Text and Format Yes/No from a Posting). I have a form with a label and a check box for each item and the user checks off the ones s/he wants to be "Yes".
12
3530
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 print the report three times, but do not know how
6
5443
by: Brett Barry: Go Get Geek! | last post by:
Hello, I have a main report with a Record Source, a DateToday table, that has the current Month and Year. I have about 60 queries, each pulling different data via ODBC, that I am creating subreports that go on the main report. The problem is that when I run the report the data shows on the screen but not the print preview. I am aware that the main report is not linked to the subreports because of the Link Master, Child Fields issue....
4
3499
by: jvan2008 | last post by:
"Form1" combobox "cboModel" Row Source SELECT ., . FROM tblModel ORDER BY ; combobox "cboContactName" SELECT . FROM Query1 ORDER BY ;
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8378
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
8890
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
8653
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
6206
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
5677
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
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2018
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.