473,396 Members | 2,061 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.

Printing a record from report?

Hi,

I have simple database based on 3 tables. Relationship is 'one to many'
between table 1 and 2, also between 2 and 3 table'one to many'.
I have made form where I enter data in all 3 tables. Form has 2 subform
based on relationships.
I want to make report to print data which is shown on form. I want to print
only data from form, not whole records from tables. Does anyone knows how to
do this? I have tried with report based on query, but I get error message.
I was trying to put criteria in query like [Forms]![Name of form]![Name of
field], but doesn't work.

Thanks in advance.
Nov 12 '05 #1
6 2227
One way to do this is by setting up a report based on a query that looks at
the form's current record and returns only that record for your report. If
you have an autonumber field in your primary table, then this gets easier,
because you can use that autonumber field as the search field in the report.
If you don't have this type of field, don't worry. It will still work if
you use the primary key field (No duplicates).

For this report, you only need to create the query for the primary table.
You can use Subreports for the child tables. This will ensure that you only
get the records for the corresponding primary table record.

This can be created as follows:

1. Open the Query editor and give it a name. Preferably "QryCurrRecord" or
something to that effect
2. Add all the fields you want in the report including the primary key.
3. In the Primary Key "Criteria" field, enter the form and field name as
follows:

=Forms!<FormName>!<fieldName>
NOTE: The form and field name most be preceeded by =Forms! or else it won't
work.

When the report opens, the query will look at the value in the primary key
field of the form and search the database's primary table for a match. When
it finds it, the report opens and the date selected for inclusion in the
report will be displayed. The subreports will then use the primary key of
the main table to populate the corresponding information in their fields.

Bob

John <jo****@hotmail.hr> wrote in message
news:bu**********@ls219.htnet.hr...
Hi,

I have simple database based on 3 tables. Relationship is 'one to many'
between table 1 and 2, also between 2 and 3 table'one to many'.
I have made form where I enter data in all 3 tables. Form has 2 subform
based on relationships.
I want to make report to print data which is shown on form. I want to print only data from form, not whole records from tables. Does anyone knows how to do this? I have tried with report based on query, but I get error message.
I was trying to put criteria in query like [Forms]![Name of form]![Name of
field], but doesn't work.

Thanks in advance.

Nov 12 '05 #2
"John" <jo****@hotmail.hr> wrote in message news:<bu**********@ls219.htnet.hr>...
Hi,

I have simple database based on 3 tables. Relationship is 'one to many'
between table 1 and 2, also between 2 and 3 table'one to many'.
I have made form where I enter data in all 3 tables. Form has 2 subform
based on relationships.
I want to make report to print data which is shown on form. I want to print
only data from form, not whole records from tables. Does anyone knows how to
do this? I have tried with report based on query, but I get error message.
I was trying to put criteria in query like [Forms]![Name of form]![Name of
field], but doesn't work.

Thanks in advance.


ONE way. Base the report on a query joining the 3 tables. Pass the
filter to the report in the open event.
DoCmd.OpenReport "MyReport",,[RecordID]=Forms!MyForm!MyField
Nov 12 '05 #3
Thanks Pieter but I couldn't make it work.
I have made Print command button on form with event
DoCmd.OpenReport "MyReport",,[RecordID]=Forms!MyForm!MyField
If I put as RecordID field from main form, I get 3 records back on report.
So, I tried to enter filter with subform, but I get the error message in VB
code "access can't find the form". I enter valid name of subform (which is
on form), but access can't find it, I don't know why.
I am newbee in this, so if you know solution please help.

Marco

"Pieter Linden" <pi********@hotmail.com> wrote in message
news:bf**************************@posting.google.c om...
"John" <jo****@hotmail.hr> wrote in message

news:<bu**********@ls219.htnet.hr>...
Hi,

I have simple database based on 3 tables. Relationship is 'one to many'
between table 1 and 2, also between 2 and 3 table'one to many'.
I have made form where I enter data in all 3 tables. Form has 2 subform
based on relationships.
I want to make report to print data which is shown on form. I want to print only data from form, not whole records from tables. Does anyone knows how to do this? I have tried with report based on query, but I get error message. I was trying to put criteria in query like [Forms]![Name of form]![Name of field], but doesn't work.

Thanks in advance.


ONE way. Base the report on a query joining the 3 tables. Pass the
filter to the report in the open event.
DoCmd.OpenReport "MyReport",,[RecordID]=Forms!MyForm!MyField

Nov 12 '05 #4
Thanks Robert, but doesn't working, I got several records in report. I have
made query based on primary table as you wrote. I have put criteria in
query, but when I add 2 subreports on report based on query with criteria
(each subreport is from other tables), I got several records back.

Marco

"Robert Gray" <gr********@erols.com> wrote in message
news:40**********************@news.rcn.com...
One way to do this is by setting up a report based on a query that looks at the form's current record and returns only that record for your report. If you have an autonumber field in your primary table, then this gets easier,
because you can use that autonumber field as the search field in the report. If you don't have this type of field, don't worry. It will still work if
you use the primary key field (No duplicates).

For this report, you only need to create the query for the primary table.
You can use Subreports for the child tables. This will ensure that you only get the records for the corresponding primary table record.

This can be created as follows:

1. Open the Query editor and give it a name. Preferably "QryCurrRecord" or something to that effect
2. Add all the fields you want in the report including the primary key.
3. In the Primary Key "Criteria" field, enter the form and field name as
follows:

=Forms!<FormName>!<fieldName>
NOTE: The form and field name most be preceeded by =Forms! or else it won't work.

When the report opens, the query will look at the value in the primary key
field of the form and search the database's primary table for a match. When it finds it, the report opens and the date selected for inclusion in the
report will be displayed. The subreports will then use the primary key of
the main table to populate the corresponding information in their fields.

Bob

John <jo****@hotmail.hr> wrote in message
news:bu**********@ls219.htnet.hr...
Hi,

I have simple database based on 3 tables. Relationship is 'one to many'
between table 1 and 2, also between 2 and 3 table'one to many'.
I have made form where I enter data in all 3 tables. Form has 2 subform
based on relationships.
I want to make report to print data which is shown on form. I want to print
only data from form, not whole records from tables. Does anyone knows how to
do this? I have tried with report based on query, but I get error

message. I was trying to put criteria in query like [Forms]![Name of form]![Name of field], but doesn't work.

Thanks in advance.


Nov 12 '05 #5
I have found solution as someone ask also this question. I have made query
based on table in each form (1 form and 2 subforms). You have to put
criteria in query: [Form]![NameofForm]![NameofPrimaryKeyFieldinForm] (this
is for form)
Criteria for query based on table in subform is:
[Form]![NameofForm]![NameofSubform]![NameofPrimaryKeyFieldinForm] (this is
for form). So there are 3 query, each with criteria.
Then I made 3 reports based on each query. Then I just put 2 reports for
subforms in main report. Main report is for form, other 2 reports are for
subform. That's it, it works.

Thanks for your answers, John
Hi,

I have simple database based on 3 tables. Relationship is 'one to many' between table 1 and 2, also between 2 and 3 table'one to many'.
I have made form where I enter data in all 3 tables. Form has 2 subform based on relationships.
I want to make report to print data which is shown on form. I want to print only data from form, not whole records from tables. Does anyone knows how to do this? I have tried with report based on query, but I get error message. I was trying to put criteria in query like [Forms]![Name of
form]![Name
of field], but doesn't work.

Thanks in advance.


ONE way. Base the report on a query joining the 3 tables. Pass the
filter to the report in the open event.
DoCmd.OpenReport "MyReport",,[RecordID]=Forms!MyForm!MyField


Nov 12 '05 #6
I have found solution as someone ask also this question. I have made query
based on table in each form (1 form and 2 subforms). You have to put
criteria in query: [Form]![NameofForm]![NameofPrimaryKeyFieldinForm] (this
is for form)
Criteria for query based on table in subform is:
[Form]![NameofForm]![NameofSubform]![NameofPrimaryKeyFieldinForm] (this is
for form). So there are 3 query, each with criteria.
Then I made 3 reports based on each query. Then I just put 2 reports for
subforms in main report. Main report is for form, other 2 reports are for
subform. That's it, it works.

Thanks for your answers, John
Nov 12 '05 #7

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

Similar topics

4
by: John Baker | last post by:
Hi: I have a form, which contains a sub form (Employee main record and payment record). It all shows up fine in a screen view, but when I come to print it I find that I cannot get the sub form...
2
by: DBQueen | last post by:
I have a database which will be printing out labels for SMALL test tubes (1/4" high). We have yet to find a reasonably-priced printer (labelwriter) which can effectively print this on ROLLS of...
1
by: Marc | last post by:
Can anyone help me! I'm trying to create an automatic printing process involving an Access database, at present I have 9 different reports set out, what I want is each report to print out using...
4
by: Sami | last post by:
I hope someone will tell me how to do this without having to do any VB as I know nothing in that area. I am a rank beginner in using Access. I have created a database consisting of student...
5
by: John | last post by:
Hi If I have a form open, what is the code that is equivalent to using the File->Print menu with select record(s) option to print the form with the currently displayed record values? Thanks ...
1
by: Casey Skousen | last post by:
I want to be able to batch print all records in a header table that have not yet been printed. This should be simple, but due to the format of the report, I cannot just print all records (the...
2
by: Simon | last post by:
Dear reader, In case a report is a sub report the Report Header of the sub report is printed in the report but the Page Header of the sub report will not be printed. This is the same for...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
it0ny
by: it0ny | last post by:
Hi guys, thanks I am fairly new to this forum so I hope I chose the right place to post this question. I try to make my program printout a deposit's report. I created a class to store the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
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
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.