Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2007

Tip: Looking for answers? Try searching our database.

Prints All Records?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mary Hartman - 04 May 2007 12:27 GMT
I did something wrong and I can't figure out what it is.

I created a print form button on a form (Access 2003).

I was careful to use the "print current form" selection.

After I fill in the form and click the print command button, Access
prints a form for every record and not just the current record for the
form I just filled in.

Anyone have any idea what I did?
RBear3 - 04 May 2007 12:42 GMT
You should print reports, not forms.  To include a button that prints a
report showing only the current record, you can use the following code...

Button to print specific record
Private Sub cmdPrint_Click()

Dim strWhere As String

       If Me.Dirty Then    'Save any edits.

               Me.Dirty = False

       End If

       If Me.NewRecord Then 'Check there is a record to print

               MsgBox "Select a record to print"

       Else

               strWhere = "[ID] = " & Me.[ID]

               DoCmd.OpenReport "MyReport", acViewPreview, , strWhere

       End If

End Sub

Notes:  If your primary key is a Text type field (not a Number type field),
you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"

If you want the report to print without preview, replace acViewPreview with
acViewNormal.

See also:  http://allenbrowne.com/casu-15.html

See also:  http://www.databasedev.co.uk/print_form_record.html

Signature

Hope that helps!

RBear3
.

> I did something wrong and I can't figure out what it is.
>
[quoted text clipped - 7 lines]
>
> Anyone have any idea what I did?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.