By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,480 Members | 763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,480 IT Pros & Developers. It's quick & easy.

Printing a record from report?

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.