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

One report layout for 3 queries

I'm pretty new to Access and VB and also know fairly little (more like nothing) about SQL.

I've got three queries that shows similar fields, the main ones being:

FIRST QUERY
Name
ID
Active member (criteria: yes)
Division in which a person belongs
Preliminary First Aid (PFA) due in 30 days
PFA due in 60 days
PFA due in 90 days
(the last 3 which are calculated fields which is based on when they actually sat the course)

SECOND QUERY
Name
ID
Active member (criteria: yes)
Division in which a person belongs
Senior First Aid (SFA) due in 30 days
SFA due in 60 days
SFA due in 90 days
(the last 3 which are calculated fields which is based on when they actually sat the course)

THIRD QUERY
Name
ID
Active member (criteria: yes)
Division in which a person belongs
Advanced First Aid (AFA) due in 30 days
AFA due in 60 days
AFA due in 90 days
(the last 3 which are calculated fields which is based on when they actually sat the course)

I've got a form that lets me select which report i want (PFA, SFA or AFA) and i want one report layout with unbound text boxes that is sorted by Division.

The problem is, how do i program the unbound text boxes in the report to refer to the relevant fields as i dont know how to link the control source either through SQL or through VB.

Thanks
Nov 20 '06 #1
9 2680
MMcCarthy
14,534 Expert Mod 8TB
What you are trying to do is a coding nightmare commonly known as dynamic reporting. Unless you are a very experienced programmer then don't even try it.

You would not just have to set the textbox values you would also have to set the labels and toggle textboxes to invisible if no data. Then there are formatting issues.

It's a lot of code and if you are trying to save time on creating three different reports this is not the way to do it.

The only way this works is if you have the same number of fields and the same labels for each field and the same datatype for each field. In that case you would only need to change the record source of the report each time.



I'm pretty new to Access and VB and also know fairly little (more like nothing) about SQL.

I've got three queries that shows similar fields, the main ones being:

FIRST QUERY
Name
ID
Active member (criteria: yes)
Division in which a person belongs
Preliminary First Aid (PFA) due in 30 days
PFA due in 60 days
PFA due in 90 days
(the last 3 which are calculated fields which is based on when they actually sat the course)

SECOND QUERY
Name
ID
Active member (criteria: yes)
Division in which a person belongs
Senior First Aid (SFA) due in 30 days
SFA due in 60 days
SFA due in 90 days
(the last 3 which are calculated fields which is based on when they actually sat the course)

THIRD QUERY
Name
ID
Active member (criteria: yes)
Division in which a person belongs
Advanced First Aid (AFA) due in 30 days
AFA due in 60 days
AFA due in 90 days
(the last 3 which are calculated fields which is based on when they actually sat the course)

I've got a form that lets me select which report i want (PFA, SFA or AFA) and i want one report layout with unbound text boxes that is sorted by Division.

The problem is, how do i program the unbound text boxes in the report to refer to the relevant fields as i dont know how to link the control source either through SQL or through VB.

Thanks
Nov 20 '06 #2
Thanks for the quick response mmccarthy.

Yes, the three queries do have the same number of fields, and same datatypes for each field. And i can make it so that all of their field name is the same in each query too.

But I dont know how to change the control sources to refer to each query.

I am doing this so i dont have to amend all three report layout if i need the report layout changed in the future. i could have easily done three reports but that means that if i change the look of one report, i have to do so with other reports.

What you are trying to do is a coding nightmare commonly known as dynamic reporting. Unless you are a very experienced programmer then don't even try it.

You would not just have to set the textbox values you would also have to set the labels and toggle textboxes to invisible if no data. Then there are formatting issues.

It's a lot of code and if you are trying to save time on creating three different reports this is not the way to do it.

The only way this works is if you have the same number of fields and the same labels for each field and the same datatype for each field. In that case you would only need to change the record source of the report each time.
Nov 20 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
Thanks for the quick response mmccarthy.

Yes, the three queries do have the same number of fields, and same datatypes for each field. And i can make it so that all of their field name is the same in each query too.

But I dont know how to change the control sources to refer to each query.

I am doing this so i dont have to amend all three report layout if i need the report layout changed in the future. i could have easily done three reports but that means that if i change the look of one report, i have to do so with other reports.
Set up the report using one of the queries.

Then change the recordsource using the following code in the report open event.


Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Report_Open(Cancel As Integer)
  3.     Me.RecordSource = "QueryName"
  4. End Sub
The queryname will have to be based on a value in your form. how are you choosing the report type. Option group, dropdown list ?
Nov 20 '06 #4
THANKS, i'll try it tonight. :) I've been pulling my hair about this aspect of the the database for about two weeks.

I'm choosing the report by command button.

Set up the report using one of the queries.

Then change the recordsource using the following code in the report open event.


Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Report_Open(Cancel As Integer)
  3.     Me.RecordSource = "QueryName"
  4. End Sub
The queryname will have to be based on a value in your form. how are you choosing the report type. Option group, dropdown list ?
Nov 20 '06 #5
MMcCarthy
14,534 Expert Mod 8TB
THANKS, i'll try it tonight. :) I've been pulling my hair about this aspect of the the database for about two weeks.

I'm choosing the report by command button.
A different command button for each report would complicate the process. With just one command button.

Create a drop down list of the three choices.

Then in the Report Open event you could use something like this:

Expand|Select|Wrap|Line Numbers
  1.  Private Sub Report_Open(Cancel As Integer) 
  2. Dim rptType As String
  3.  
  4.   rptType = Forms![FormName]![ComboBoxName]
  5.  
  6.   If rptType = "XXX" Then
  7.     Me.RecordSource = "QueryName1"
  8.   ElseIf rptType = "YYY" Then
  9.     Me.RecordSource = "QueryName2"
  10.   ElseIf rptType = "ZZZ" Then
  11.     Me.RecordSource = "QueryName3"
  12.   End If
  13.  
  14. End Sub
  15.  
Nov 20 '06 #6
NeoPa
32,556 Expert Mod 16PB
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer) 
  2.   Select Case Forms![FormName]![ComboBoxName]
  3.   Case "XXX"
  4.     Me.RecordSource = "QueryName1"
  5.   Case "YYY"
  6.     Me.RecordSource = "QueryName2"
  7.   Case "ZZZ"
  8.     Me.RecordSource = "QueryName3"
  9.   End Select
  10. End Sub
-'Select Evangelist' ;)
(I'll convert Mary yet!)
Nov 20 '06 #7
MMcCarthy
14,534 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer) 
  2. Select Case Forms![FormName]![ComboBoxName]
  3. Case "XXX"
  4. Me.RecordSource = "QueryName1"
  5. Case "YYY"
  6. Me.RecordSource = "QueryName2"
  7. Case "ZZZ"
  8. Me.RecordSource = "QueryName3"
  9. End Select
  10. End Sub
-'Select Evangelist' ;)
(I'll convert Mary yet!)
I knew as soon as I'd posted it you'd be in here mouthing off.



Have to leave you something to do. Keep trying to convert me.



Mary
Nov 20 '06 #8
Thanks for the answer,
I tried it last night and it worked like a gem. :)
Nov 20 '06 #9
MMcCarthy
14,534 Expert Mod 8TB
Thanks for the answer,
I tried it last night and it worked like a gem. :)
You're welcome.
Nov 20 '06 #10

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

Similar topics

3
by: mark | last post by:
How do I get all fields on one page of a report? I have a report that has a column for each day of the week and 6 records for each day. I need each weekday's records returned on only one detail...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
1
by: teresaalmond | last post by:
Ok.. I have a table where people add and delete records when machines are sold or new ones brought into inventory. I know.. this isn't a good business practice, but thats how they do it. What I...
6
by: geronimo_me | last post by:
I have 20 queries that compare fields in one table with fields in another table - the query results are the records that do not match in Table1 and Table2. ie Table1 DOB 28/02/78 Table2 DOB...
1
by: prabhukalyan | last post by:
Hi all, I am not so good in queries. here is my problem 2 tables to store the received items (fabric)-- inwardmaster, inwarddetails and after some processing (Dyeing) the items were...
10
by: john | last post by:
I have a report to print envelopes. The report is based on a query. Now I need to make 10 more queries to make different selections of addresses. Every query has the same output fields as the...
4
by: Jana | last post by:
Hi! I have an Access 97 report based on tables linked to an SQL back end. The report has 5 subreports in it (unfortunately unavoidable due to the nature of the report) and performance is quite...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
9
by: magickarle | last post by:
Hi, I have a database in access with the following columns: Day AgentID ManagerID Grade They got information about agents and some grades. I would like to have ONE form with several...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
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,...
0
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...
0
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...
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,...

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.