473,405 Members | 2,444 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,405 software developers and data experts.

Print different reports based on field value?

7
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 4418
Stewart Ross
2,545 Expert Mod 2GB
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
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 Expert Mod 2GB
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.OpenRecordset("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
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
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...
3
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...
8
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...
2
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...
3
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...
4
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...
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...
6
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...
4
by: jvan2008 | last post by:
"Form1" combobox "cboModel" Row Source SELECT ., . FROM tblModel ORDER BY ; combobox "cboContactName" SELECT . FROM Query1 ORDER BY ;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.