Creating a button to print the current record

G

Guest

I want to put a button on my form that would allow the user to print ONLY
that record and not the whole database. I received a the code:
me.Refresh
docmd.openreport "myreprot",acViewPreview,,"id = " & me!id

I am a novice at MS Access and am not sure how to personalize this since as
written it doen not work. I want to print a form and not a report. Can I
change to docmd.openform "EHSR_1"
Also, the "id =" thing really confused the program.

Thanks for the help.

David
 
G

garret

I think the only way to do this, is when you go to print, there should
be a few option buttons in the print options box (before you print)
that say 'print all records' or 'print selected record only'. You have
to click the latter of these two and then it will just print 1 form
with the record you have selected on it.
 
G

Guest

I have seen forms that had a print button at the bottom of the form that
would print that record (the current record). I can create a button on the
form to print the entire database but not the single form. I understand
about going to the print function and telling it to print the selected record
but I want to have the button right on the sheet so that someone doesn't
accidentally print the whole database.

Thanks
 
A

Albert D.Kallal

I want to put a button on my form that would allow the user to print ONLY
that record and not the whole database. I received a the code:
me.Refresh
docmd.openreport "myreprot",acViewPreview,,"id = " & me!id

I am a novice at MS Access and am not sure how to personalize this since
as
written it doen not work. I want to print a form and not a report.

No no no. Forms are for data entry, reports are for printing. You will
suffer grief, pain, and difficulty if you try and print forms. They are just
not designed for that. Build a report, as they are printer friendly (and
stuff like back grounds, etc would not have to print).

So, build a report. lay it out the way you want, and you can even make it
look like the screen if you want. However, with a report, you can put things
like user name who printed, what workstation, time of day, page number...all
kinds of things that you don't necessary have on the form.

So, save yourself pain, grief, difficulty in maintains, and simply all
around a bad idea to use the form to print. Build, and layout your report,
as they are MUCH more printer friendly, and a designed for this task.

You then use
me.refresh ' this forces a disk write
docmd.openreport "myreprot",acViewPreview,,"id = " & me!id

You change "myreprot" to the name of the report you will make...

Change "id = " & me!id to whatever field name you used for the primary key
(the default is id....).

So, if you used in place of "id" as your primary key customerid, then you
use

"CustomerID = " & me!CustomerID
 
G

Guest

OK, I created the report and was trying to put the button on the report to
print that page only. Can you put active buttons on a report or d othey have
to go somewhere else? I can put a command button on it but it wont do
anything.

Almost there.

Thanks

david
 
G

Guest

Never mind. I figured it out. You put the button on the forms page to print
the report.

Thanks for everything.

David
 
R

reportyemi

this is what i have but it still is not opening the print button


Private Sub Command195_Click()
DoCmd.OpenReport "labor_record", acViewPreview, , "[maternal_ID]=" &
[Maternal_ID]
End Sub
 
D

Damon Heron

Put the command button on the Form. When clicked, it will print the current
record with matching maternal_ID.

Damon

reportyemi said:
this is what i have but it still is not opening the print button


Private Sub Command195_Click()
DoCmd.OpenReport "labor_record", acViewPreview, , "[maternal_ID]=" &
[Maternal_ID]
End Sub



DDrowe said:
OK, I created the report and was trying to put the button on the report
to
print that page only. Can you put active buttons on a report or d othey
have
to go somewhere else? I can put a command button on it but it wont do
anything.

Almost there.

Thanks

david
 

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