Report directly from a sub form

G

Guest

I have a Sunday School data base that has a form set up with many tabs that
are the children of the families in our church. I have numerous reports that
I would like to print (name tags, parent tags, letters, etc.) that I would
like to print directly from the open subform. How would I go about setting
up a command button on the sub form to print the various reports or one
button for each report for the child that is currently open in the sub form.

Thanks
 
G

Guest

Hi.
For a simple data table you could use a query as the source for your report
and set the criteria for a unique field, probably an ID field to the field
containing that same ID on the form something like me.ID. You could also
look at the instructions below.
I got this from a previous post.
In the Click event procedure of your command button, use OpenReport with the
WhereCondition to limit it to the current record.
You need to save the record before the latest edits show in the report, and
there is no current record if the form is at a new record.
The example below shows what to put in the Event Procedure (code) for the
button's Click event. It assumes a numeric primary key named "ID":
Private Sub cmdPreview_Click()
Dim strWhere As String
If Me.Dirty Then 'Save
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Pick a record to print."
Else
strWhere= "[ID] = " & Me.ID
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub

Hope this helps.
Fons
 

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