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 / Reports / Printing / February 2006

Tip: Looking for answers? Try searching our database.

Preview report ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SpookiePower - 13 Feb 2006 15:36 GMT
I have made a form that shows one customer at a time
from a table. I have put a Preview-report-button on the
form and it works fine..almost. The problem is that it shows
a report with all the customers from the table.

I want the user to be able to view a report that only
shows the one customer that the user is currently
viewing on the form.

How is this possible ?

www.photo.activewebsite.dk
Rick B - 13 Feb 2006 16:03 GMT
Here is a sample from a similar button on one of my forms.  You can adjust
it to meet your needs
Signature

Rick B

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

>I have made a form that shows one customer at a time
> from a table. I have put a Preview-report-button on the
[quoted text clipped - 8 lines]
>
> www.photo.activewebsite.dk
SpookiePower - 13 Feb 2006 16:10 GMT
Thanks.

This is excat what I'm looking for :)
I'll take a look at it to see if I can get it to work in my example.
Wayne Morgan - 13 Feb 2006 16:05 GMT
In the DoCmd.OpenReport command in the button's Click event, you need to use
the WhereCondition argument to pass the unique ID field value of the current
record on the form.

Example:
DoCmd.OpenReport "MyReport", acViewPreview,, "[IDField] = " & Me.txtIDField

The syntax above assumes the IDField to be a number data type.

Signature

Wayne Morgan
MS Access MVP

>I have made a form that shows one customer at a time
> from a table. I have put a Preview-report-button on the
[quoted text clipped - 8 lines]
>
> www.photo.activewebsite.dk
SpookiePower - 13 Feb 2006 16:55 GMT
Thanks to both of you.

It works just perfect :)
 
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



©2008 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.