Create Report from Form - Still need help

D

Dee

I sent the email below to the newsgroups:
I want to create a database for tracking sample requests.
We have a huge inventory of blood samples where scientists
requests particular samples to run tests. I would like to
create a form for them to complete in Access and then
print out as a hard copy of the sample request. How would
I create a report to print out the information on just the
form they completed. For instance, they would go into the
Access form and complete the form then print the form as a
report to hand out as a hard copy for signature. I am
using Access 2000.

I got the following response from Alan:

Yes, make a report based on the same query you used for
the form. You need to have a Primary Key for each record
such as an Autonumber. Make sure the Primary Key field is
included in the query even if you don't use it as a text
box. Then create a button that opens the report using the
primary key as the Where criteria. The button would be on
the same form that the doctor inputs the data. The On
Click code for the button that opens the report would then
look like this:

DoCmd.OpenReport "YourReportName",
acPreview, ,"[PrimaryKeyFieldName]= "
me.[PrimaryKeyFieldName]

(all the above would need to be on on line. This dialog
box makes it look like three lines)

This will open the report for the unique record the doctor
is on because of the Primary key.

I am still having difficulty. When I put the code into the
on click event of the button, the button opens the report,
but it only gives me a blank report. The field labels are
there but not the completed fields. Could anyone tell me
what I am doing wrong. How do I get the button to open
the report on the record of the form I just completed.

Thanks very much for your help. You guys are great!

Best regards,

Dolores
 
M

Marshall Barton

Dee said:
I sent the email below to the newsgroups:
I want to create a database for tracking sample requests.
We have a huge inventory of blood samples where scientists
requests particular samples to run tests. I would like to
create a form for them to complete in Access and then
print out as a hard copy of the sample request. How would
I create a report to print out the information on just the
form they completed. For instance, they would go into the
Access form and complete the form then print the form as a
report to hand out as a hard copy for signature. I am
using Access 2000.

I got the following response from Alan:

Yes, make a report based on the same query you used for
the form. You need to have a Primary Key for each record
such as an Autonumber. Make sure the Primary Key field is
included in the query even if you don't use it as a text
box. Then create a button that opens the report using the
primary key as the Where criteria. The button would be on
the same form that the doctor inputs the data. The On
Click code for the button that opens the report would then
look like this:

DoCmd.OpenReport "YourReportName",
acPreview, ,"[PrimaryKeyFieldName]= "
me.[PrimaryKeyFieldName]

(all the above would need to be on on line. This dialog
box makes it look like three lines)

This will open the report for the unique record the doctor
is on because of the Primary key.

I am still having difficulty. When I put the code into the
on click event of the button, the button opens the report,
but it only gives me a blank report. The field labels are
there but not the completed fields. Could anyone tell me
what I am doing wrong. How do I get the button to open
the report on the record of the form I just completed.


You have to replace the names of the report and the key
field with the names you are actually using.

You are also missing an &

DoCmd.OpenReport "YourReportName", acPreview, , _
"[PrimaryKeyFieldName]= " & Me.[PrimaryKeyFieldName]
 
F

Fons ponsioen

Marsh and Dee. Depending onthe record you are trying to
print, You may have to save the record first if this is a
newly added record. you can add the record save line
before printing the report.
Fons
-----Original Message-----
Dee said:
I sent the email below to the newsgroups:
I want to create a database for tracking sample requests.
We have a huge inventory of blood samples where scientists
requests particular samples to run tests. I would like to
create a form for them to complete in Access and then
print out as a hard copy of the sample request. How would
I create a report to print out the information on just the
form they completed. For instance, they would go into the
Access form and complete the form then print the form as a
report to hand out as a hard copy for signature. I am
using Access 2000.

I got the following response from Alan:

Yes, make a report based on the same query you used for
the form. You need to have a Primary Key for each record
such as an Autonumber. Make sure the Primary Key field is
included in the query even if you don't use it as a text
box. Then create a button that opens the report using the
primary key as the Where criteria. The button would be on
the same form that the doctor inputs the data. The On
Click code for the button that opens the report would then
look like this:

DoCmd.OpenReport "YourReportName",
acPreview, ,"[PrimaryKeyFieldName]= "
me.[PrimaryKeyFieldName]

(all the above would need to be on on line. This dialog
box makes it look like three lines)

This will open the report for the unique record the doctor
is on because of the Primary key.

I am still having difficulty. When I put the code into the
on click event of the button, the button opens the report,
but it only gives me a blank report. The field labels are
there but not the completed fields. Could anyone tell me
what I am doing wrong. How do I get the button to open
the report on the record of the form I just completed.


You have to replace the names of the report and the key
field with the names you are actually using.

You are also missing an &

DoCmd.OpenReport "YourReportName", acPreview, , _
"[PrimaryKeyFieldName]= " & Me. [PrimaryKeyFieldName]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top