getting a record and its subdatasheet to print

G

Guest

How can I print a record and its subdatasheet in a table? I expanded to view the subdatasheet with the record and selected the record in the record selector bar of the main table that is open. I click PRINT SELECTED RECORD but only the record and its data from the original table prints - not the subdatasheet data

What am I doing wrong

Thanks

wendy
 
A

Allen Browne

For printing, you need a report.

1. Create a query into the main table and the table used by the
subdatasheet. Save.

2. Create a report based on this query, and laid out how you want it to
print. Save as (say) "MyReport".

3. Add a command button to your form. Set its On Click property to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.

4. Place this code into the event procedure. The code assumes the main
form's table has a primary key (autonumber) named "ID" that uniquely
identifies the record to print:

Private Sub cmdPrint_Click()
If Me.Dirty Then 'save
Me.Dirty = False
End If
DoCmd.OpenReport "MyReport", acViewPreview, , "[ID] = " & Me.[ID]
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

wendy said:
How can I print a record and its subdatasheet in a table? I expanded to
view the subdatasheet with the record and selected the record in the record
selector bar of the main table that is open. I click PRINT SELECTED RECORD
but only the record and its data from the original table prints - not the
subdatasheet data.
 

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