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

Report Creation With Query

Hi all,

I create a report to act as a receipt to customers.
The report displays all the customer payment details and then i print
this.
This works fine. However, i now want to add some more information to
this page. But i cant seem to do it.

The report uses a query to pull in the data from the form.I have a drop
down on my form called costcode1
This shows 3 colmns when you click on it.
1 Colmn shows the cost code, the second colmn shows a description of
what that code relates to.

In my query to create the report i want to be able to pull in that
second colmn and not the costcode which is displayed on the form. As
the code would be meaningless to our customers.

How can i do this? Do i do it in the query?

Many thanks in advance!!!

Nov 29 '05 #1
18 2331
Yes, create a query that contains both the table your form uses as its
RecordSource, and also the table that the combo uses as its RowSource.

In query design view, you will see a line joining the 2 tables. Double-click
this line. Access pops up a dialog offering 3 choices. Choose the one that
says:
All records from [Your form's table], and any matches from [Your combo's
table.]

This way, all records are included in the report, even if the combo was left
blank. If you want more info on that, see:
The Query Lost My Records
at:
http://allenbrowne.com/casu-02.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<si************@gmail.com> wrote in message
news:11********************@g47g2000cwa.googlegrou ps.com...

I create a report to act as a receipt to customers.
The report displays all the customer payment details and then i print
this.
This works fine. However, i now want to add some more information to
this page. But i cant seem to do it.

The report uses a query to pull in the data from the form.I have a drop
down on my form called costcode1
This shows 3 colmns when you click on it.
1 Colmn shows the cost code, the second colmn shows a description of
what that code relates to.

In my query to create the report i want to be able to pull in that
second colmn and not the costcode which is displayed on the form. As
the code would be meaningless to our customers.

How can i do this? Do i do it in the query?

Many thanks in advance!!!

Nov 29 '05 #2
There are no lines.

My form uses CustomerPaymentsDetails table as record source

And combo box uses table costCodePlanning as record source.

costCodePlanning has 3 colmns - department, CodeDescription, Code.

When a selection is made it is stored in CustomerPaymentsDetails under
colmn called costcode1.

How do i get these lines you speak of?

Cheers

Nov 29 '05 #3
So CustomerPaymentDetails.costcode1 matches costCodePlanning.Code?

In query design, click on costcode1 in the CustomerPaymentDetails, and drag
it onto Code in costCodePlanning. Access will give you the join.

I imagine it would be a good idea to create this relationship between the 2
tables. You can do that in the Relationships window (Relationships on Tools
menu.) Then Access will automatically give you the joins in your queries.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<si************@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
There are no lines.

My form uses CustomerPaymentsDetails table as record source

And combo box uses table costCodePlanning as record source.

costCodePlanning has 3 colmns - department, CodeDescription, Code.

When a selection is made it is stored in CustomerPaymentsDetails under
colmn called costcode1.

How do i get these lines you speak of?

Cheers

Nov 29 '05 #4
Excellent this worked fine!!

Thanks for that.

So now in my query i've selected another field CodeDescription from
costcodePlanningBuildingControl table.

When i go to print the receipt however it prints every description on
20 different pages.

So do i need to put something in the criteria? I tried
[Forms]![SavedRecordsForm]![CostCode1] But this then didnt print
anything in the textboxes.

Sorry im still learning. Hope you can help

Cheers

Nov 29 '05 #5
See:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<si************@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Excellent this worked fine!!

Thanks for that.

So now in my query i've selected another field CodeDescription from
costcodePlanningBuildingControl table.

When i go to print the receipt however it prints every description on
20 different pages.

So do i need to put something in the criteria? I tried
[Forms]![SavedRecordsForm]![CostCode1] But this then didnt print
anything in the textboxes.

Sorry im still learning. Hope you can help

Cheers

Nov 29 '05 #6
Hi thanks for the help

I've put the following code onto my form

Private Sub btnPrintReceipt_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[RECEIPT NUMBER] = """ & Me.[RECEIPT NUMBER] & """"
DoCmd.OpenReport "Customer Receipt2", acViewPreview, , strWhere
End If
End Sub

It've set RECEIPT NUMBER to be the primary key in the
CustomerPaymentDetails table. The form is called Customer Receipt2
And i've done what you said earlier about joining a line between the
tables.

The report opens now but there is nothing in the text boxes. They are
now all empty!

Please help.

Thanks very much for the help so far.
Nearly there

Nov 30 '05 #7
When you open your table in design view, what is the Data Type of your
RECEIPT NUMBER field?

It is is Number (not Text), lose the extra quotes, i.e.:
strWhere = "[RECEIPT NUMBER] = " & Me.[RECEIPT NUMBER]

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<si************@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi thanks for the help

I've put the following code onto my form

Private Sub btnPrintReceipt_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[RECEIPT NUMBER] = """ & Me.[RECEIPT NUMBER] & """"
DoCmd.OpenReport "Customer Receipt2", acViewPreview, , strWhere
End If
End Sub

It've set RECEIPT NUMBER to be the primary key in the
CustomerPaymentDetails table. The form is called Customer Receipt2
And i've done what you said earlier about joining a line between the
tables.

The report opens now but there is nothing in the text boxes. They are
now all empty!

Please help.

Thanks very much for the help so far.
Nearly there

Nov 30 '05 #8
Hi
I'm afraid it is text. So i put the extra quotes in.

RECEIPT NUMBER
BCCA - 00001
BCCA - 00002
BCCA - 00003

Thanks for the swift reply!!!!

Nov 30 '05 #9
Just above the DoCmd.OpenReport line, add this line:
Debug.Print strWhere

When the report opens with no records, press Ctrl+G to open the Immediate
Window, and look at the filter string you have applied. Can you see why this
yields no match?

If you mock up a query, and use that expression in the WHERE clause, does
the query return a match?

Your example shows a dash in the value, so you may have struck this bug:
Query Returns no Records with an Indexed Field That Contains Dashes
at:
http://support.microsoft.com/default...b;en-us;271661

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<si************@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Hi
I'm afraid it is text. So i put the extra quotes in.

RECEIPT NUMBER
BCCA - 00001
BCCA - 00002
BCCA - 00003

Thanks for the swift reply!!!!

Nov 30 '05 #10
Sorry i've just realised what my problem was i had put something in the
criteria for CodeDescription and nothing had that criteria so nothing
was being displayed.
Thankyou sooooo much for your help it all works great now!!!

Cheers Allen!! :)

Nov 30 '05 #11
Ah i removed what was in the criteria and now its diplaying all the
CodeDecripts on 20 pages!!

:(

Ahhhh

Nov 30 '05 #12
God does this to posters who do not tell us at the beginning that
"i had put something in the criteria for CodeDescription".
On the second occurrence it's Thunderbolts!

Nov 30 '05 #13
Keep working on it.
You will build the desired string, just like the WHERE clause of a query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<si************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Ah i removed what was in the criteria and now its diplaying all the
CodeDecripts on 20 pages!!

:(

Ahhhh

Nov 30 '05 #14
Sorry Lyle but i did say

So do i need to put something in the criteria? I tried
[Forms]![SavedRecordsForm]![CostCode1] But this then didnt print
anything in the textboxes ..Yesterday.

I just forget where i put things as i'm new to programming and access.
And having a time getting my head round it all.

Do i need something in criteria or not? Not sure now as im soo
oconfused :S

Nov 30 '05 #15
If i say [Forms]![SavedRecordsForm]![CostCode1_combobox] in the
criteria then do i have to say that its the first colmn of the dropdown
combobox?

Seems logical to me.

I've got this for my button on my form.
Private Sub btnPrintReceipt_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[RECEIPT NUMBER] = """ & Me.[RECEIPT NUMBER] & """"
Debug.Print strWhere

DoCmd.OpenReport "Customer Receipt2", acViewPreview, , strWhere
End If

The rowsource for my CostCode1_combobox is

SELECT costcodePlanningBuildingControl.code,
costcodePlanningBuildingControl.CodeDescription,
costcodePlanningBuildingControl.Department FROM
costcodePlanningBuildingControl ORDER BY
costcodePlanningBuildingControl.Department,
costcodePlanningBuildingControl.CodeDescription;

My query i have
Field: CodeDescription
Table: costcodePlanningBuildingControl

And costcodePlanningBuildingControl

has these values...

Building Control Application Fees 7221000 94275B
Building Control Application Fees(RG) 7221000 94275G
Building Control Site Inspection Fees 7221000 94240B
Building Control Seminar Fees 7221000 43239E
Building Control Building Notice Fees 7221000 94279B
Building Control OS fees 7221000 93014F
Building Control Photocopying/Info Fees 7221000 94232B
Building Control Leisure Services 4223060 94998
Planning Conservation Income 7211200 94286
Planning Personal Phone Calls 7211300 41312B
Planning Planning Applications 7211300 94270G
Planning HM Land Registry Funds 7211300 46038G
Planning Minor Amendment Fee(£75) 7211300 94276G
Planning PD Enquiry(£40) 7211300 94277G
Planning Economic Development Business Directory 7244001 94498F
Planning Leisure-Hway Searches 1444000 94412G
Planning Notices & Reps 7211300 94237B
Planning Written Enquiry Fees 7211300 94237G
Planning Misc Income 7211300 99099
Planning Mayoral Book 7211300 94309F

Nov 30 '05 #16
That will refer to whichever is the Bound column of your combo.

I will bow out now, and let you take it from there.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<si************@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
If i say [Forms]![SavedRecordsForm]![CostCode1_combobox] in the
criteria then do i have to say that its the first colmn of the dropdown
combobox?
Nov 30 '05 #17
Thanks guys.

I've sorted it! Finally i think!

I added code and code description to the query

Put [Forms]![SavedRecordsForm]![CostCode1_combobox] as criteria for
code. And then wrote code description on the form but not code.

YAY! I can relax now PHEW!!!!

Thanks again!!!! :D

Nov 30 '05 #18
Monring all!

Now i need to get the description of each code for 3 dropdown combo
boxes.
I've just realised if i use code description in the query i will only
look for the first code description based upon the code shown in
CostCode1_combobox

I've got two more... CostCode2_combobox CostCode3_combobox and i want
to display the descriptions of these in seperate text boxes.

I've sorted the relationships for all 3 now.

Is this at all possible??

Many thanks :)

Dec 1 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
3
by: lorirobn | last post by:
Hello, I'm creating a one-page report that will display only total counts, no details. I want to examine the values of 2 fields on the source table, and add to appropriate counters accordingly....
0
by: z.ghulam | last post by:
Hi, I'm creating a new databse and have a couple of problems I'd greatly appreciate any feedback on. 1) I have an order form and would like to set it, so that when the form is opened, the focus...
6
by: Les Juby | last post by:
I need to extract records from a database subject to conditions and only thereafter give the users the choice of which fields to sort the results on. In this situation I can't write back to a...
5
by: jmar | last post by:
I posted a week ago and received one response. I'm looking for the opinion of several experienced .NET people before I proceed so I'm posting again. Sorry for the repost... I am updating a...
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,...
2
by: blackduck603 | last post by:
Hi, I am fairly new to Access programming and Reports. I have inherited a project and am trying to understand some of the inner workings. There is a field named Overall in the Detail section of my...
3
by: agarwalsunitadhn | last post by:
hi... Currently i have a need for creation of crystal report. here user search according to some criteria and i want to display that search data in crystal report. So here what i need is to bind...
10
by: Snoopy33 | last post by:
I have a DB that I developed on access XP (2002) and deployed over a year ago. No one has had problems printing any of the reports within the DB until we started loading 2007 on new computers. ...
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?
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
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
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
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...
0
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...

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.