472,119 Members | 2,144 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Print the current record of a form

I have a form that consists of 150 records and is still growing.
there are times when I want to print a certain record of the form, say
record 12. I go to file --> print and choose the page number of the
record. But what I would like to do, to decrease the amount of
mistakes of print all 150+ records, I would like a button to only
print the record that is currently displayed on screen. I know it can
be done, I just don't know how. Any suggestions? Thanks!
Nov 13 '05 #1
2 3365
On 17 Jun 2004 13:17:38 -0700, pm*****@thelyndco.com (Paul Mendez) wrote:
I have a form that consists of 150 records and is still growing.
there are times when I want to print a certain record of the form, say
record 12. I go to file --> print and choose the page number of the
record. But what I would like to do, to decrease the amount of
mistakes of print all 150+ records, I would like a button to only
print the record that is currently displayed on screen. I know it can
be done, I just don't know how. Any suggestions? Thanks!


First of all you shouldn't really be printing the form. Forms are for viewing, reports are for printing.
Create a report containing the same info as shown on the form. As a starting point you can right click on the form name
in the database window and select "Save as report". This will generate a report which will look the same as your form,
which you can then edit to suit your needs. (eg remove unwanted controls such as command buttons etc)

Make sure that both your form and report's recordsource contains the Primary Key field of the records.
Add a command button to your form (cmdPrint) and put the following code in the OnClick event of the button -

DoCmd.OpenReport "rptMyReport",,,"[PrimaryKeyField]=" & Me.PrimaryKeyField

Change rptMyReport to the name of your report.
Change PrimaryKeyField to the name of your primary key field.

This will print a single record report showing details of the current record in the form.
Wayne Gillespie
Gosford NSW Australia
Nov 13 '05 #2
Hi Paul,
In Access97 at least ... this is how it's done.

Private Sub cmdPrintCurrentRecord_Click()
On Error GoTo Err_cmdPrintCurrentRecord_Click

'The Wizard does it this way:
'DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70

'But I prefer:
DoCmd.RunCommand acCmdSelectRecord
DoCmd.PrintOut acSelection

Exit_cmdPrintCurrentRecord_Click:
Exit Sub

Err_cmdPrintCurrentRecord_Click:
MsgBox Err.Description
Resume Exit_cmdPrintCurrentRecord_Click
End Sub

HTH,
Don
Paul Mendez <pm*****@thelyndco.com> wrote in message
news:99************************@posting.google.com ...
I have a form that consists of 150 records and is still growing.
there are times when I want to print a certain record of the form, say
record 12. I go to file --> print and choose the page number of the
record. But what I would like to do, to decrease the amount of
mistakes of print all 150+ records, I would like a button to only
print the record that is currently displayed on screen. I know it can
be done, I just don't know how. Any suggestions? Thanks!

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by sea | last post: by
1 post views Thread by Randy | last post: by
3 posts views Thread by simonmarkjones | last post: by
reply views Thread by leo001 | last post: by

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.