J
justme
Following an example on another post (I believe by Allen), I put a button on
my form which prints out a report of the current record.
frmOrderStatus contains fields from table tFits and also contains 3
subreports:
On Tab1:
1. sfmCommentLatest - linked on Style_pk & Style_fk
-displays latest comment from tComments table, according to timestamp
2. sfmOSOrders - linked on Style_pk & Style_fk, located on tab1
-displays many fields queried from table tOrders
On Tab2:
3. sfmCommentsHistory - linked on Style_pk & Style_fk, located on tab2
-displays all comments from tComments table for the current style on
Parent form
I made a report layout called "rptStyleOSSummary" to print out all the same
info as on the first tab.
I placed a button on my parent form, "frmOrderStatus", with following click
event.
Private Sub btnPrintRecMain_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 = "[Style_pk] = """ & Me.[Style_pk] & """"
DoCmd.OpenReport "rptStyleOSSummary", acViewPreview, , strWhere
End If
End Sub
This works perfectly, bringing up the report, displaying all the info for
the current record. ...EXCEPT when there is no comment in the comments table
for that style. Then, the report is called up with no style in the linked
field, and errors all around in the other fields.
Help?
Thank you.
my form which prints out a report of the current record.
frmOrderStatus contains fields from table tFits and also contains 3
subreports:
On Tab1:
1. sfmCommentLatest - linked on Style_pk & Style_fk
-displays latest comment from tComments table, according to timestamp
2. sfmOSOrders - linked on Style_pk & Style_fk, located on tab1
-displays many fields queried from table tOrders
On Tab2:
3. sfmCommentsHistory - linked on Style_pk & Style_fk, located on tab2
-displays all comments from tComments table for the current style on
Parent form
I made a report layout called "rptStyleOSSummary" to print out all the same
info as on the first tab.
I placed a button on my parent form, "frmOrderStatus", with following click
event.
Private Sub btnPrintRecMain_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 = "[Style_pk] = """ & Me.[Style_pk] & """"
DoCmd.OpenReport "rptStyleOSSummary", acViewPreview, , strWhere
End If
End Sub
This works perfectly, bringing up the report, displaying all the info for
the current record. ...EXCEPT when there is no comment in the comments table
for that style. Then, the report is called up with no style in the linked
field, and errors all around in the other fields.
Help?
Thank you.