Printing a selected report from a subform

G

Guest

Wonder if anyone can please help.
I want to print only selected records from a subform.
My main form [Newform] contains individuals name, address etc. The subform
[AppointmentDetailsSubform] contains specific appointment details. Both forms
are linked on a number field.
I want to be able to print out specific appointment letters from the
subreport, but when I print the report I get all records.
I'm afraid my knowledge of VB is pretty low.

Any help appreciated.
Thanks
 
G

Gina Whipp

Without seeing the code you do have, a few suggestions...

If a text field: strWhere = "[NameOfFieldInTable]=' " &
Me![NameOfFieldOnReport] & " ' "
If a numeric field: strWhere = "[NameOfFieldInTable]=" &
Me![NameOfFieldOnReport]


Dim stDocName As String
Dim strWhere As String

strWhere = SEE ABOVE

stDocName = "NameOfYourReport"
DoCmd.OpenReport stDocName, acPreview, strWhere

OR 1 line

DoCmd.OpenReport "NameOfYourReport", acPreview, , "[NameOfFieldInTable]=" &
Me![NameOfFieldOnReport]

watch out for word wrap...

HTH,
Gina Whipp
 

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