View Single Post
  #4  
Old April 10th, 2010, 06:46 AM posted to microsoft.public.access.gettingstarted
Duane Hookom[_4_]
external usenet poster
 
Posts: 316
Default Printing a single record from a tab control subform

Learn the basics of trouble-shooting. Try add a msgbox, debug.Print, or
breakpoint to your code so you know if the code is being run:
Also, always provide the significant data types. Is ID_General text or
numeric?

Private Sub Print_Click()

Dim strDocName As String
Dim strWhere As String
strDocName = "R1-1 GPS_GeneralInfo"
strWhere = "[ID_General] = " & Me.[ID_General]
debug.print "strWhe " & strWhere
MsgBox "strWhe " & strWhere
DoCmd.OpenReport "R1-1 GPS_GeneralInfo", acPreview, , strWhere

End Sub


--
Duane Hookom
MS Access MVP


"forest8" wrote in message
...
Hi

This is the code for the print function as an Event procedure. I'm not
sure
what I'm missing.

Private Sub Print_Click()

Dim strDocName As String
Dim strWhere As String
strDocName = "R1-1 GPS_GeneralInfo"
strWhere = "[ID_General] = " & Me.[ID_General]
DoCmd.OpenReport "R1-1 GPS_GeneralInfo", acPreview, , strWhere

End Sub

The name of the report is R1-1 GPS_GeneralInfo
The primary key of the subform is "ID_General"

The main form is called GPS. One of the subforms in the tabcontrol is
called
General.

I saved the GPS form and General form as reports (by using save as). Then
I
created the report by using the GPS form as the report and the General
form
as the subreport. The Masterlink is GPSID and the ChildLinkID is GPSID_FK.

The form doesn't have the primary key in it. It's just in the Table called
T_General.

I should also mention that the Print button with the Click event is on the
subform in the tabcontrol.

If I can get this one report to work, I can use the same logic and fix all
the other reports in my database.

Thank you.


"Duane Hookom" wrote:

What makes you think your "Print" button should work? How did you create
it?
Did you use the wizard? What is the code?


--
Duane Hookom
MS Access MVP


"forest8" wrote in message
...
Hi

I have created a Case Management Database of students. It consists of a
main
form
and a subform. The main form consists of information that must be seen
at
all times. since it consists of information about each student.

The subform consists of a tab control. There is a different subject on
each
page of the tab contol, e.g. General Information, Current Student
Information, etc.

I need to print out the mainform and subforms so I created reports for
each
subform in my tab control.

I want to put a "Print" button on each page of my tabcontrol so that
when
clicked, that specific report for that particular record is printed?

The thing is that my "Print" button does not work. That is, when I
click
on
it, nothing happens.

How do I fix it so that it prints that report for that particular
record?

Thank you for your help in advance.