Preview report ?

  • Thread starter Thread starter SpookiePower
  • Start date Start date
S

SpookiePower

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
 
Here is a sample from a similar button on one of my forms. You can adjust
it to meet your needs
--
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
 
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.
 
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.
 
Back
Top