C
Clare
I have a comand button on my form which opens a popup containing a list of
reports to print. I have the following code which when placed on the main
form will use only the current record for the report.
Private Sub cmdPrintfees1_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 = "[ExternalExaminerID] = " & Me.[ExternalExaminerID]
DoCmd.OpenReport "RptFees,report", acViewPreview, , strWhere
End If
End Sub
But that won't work on my popup because of 'invalid use of the me.Dirty'
I have the following code which works in the popup and brings up the report,
but brings up a report for every record instead of just the current record.
The report list comes from a query using the MsysObjects table.
Private Sub lstReports_DblClick(Cancel As Integer)
ShowReports lstReports.Value, Forms!AMainform
End Sub
Function ShowReports(strReportName As String, frm As Form) As Integer
On Error Resume Next
Dim strWhereCond As String
strWhereCond = "MyField = " & frm!MyField
DoCmd.OpenReport strReportName, acViewPreview, , strWhereCond
If Err > 0 Then
'OpenReport failed
MyFunction = False
Else
MyFunction = True
End If
Exit Function
End Function
I admit I have just copied and pasted these and taken them from other help
topics so I don't actually completely understand it all. How do I make the
single record code work in the popup? Or how do I change the popup code to
take just the record that's in the main form?
Thanks very much.
reports to print. I have the following code which when placed on the main
form will use only the current record for the report.
Private Sub cmdPrintfees1_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 = "[ExternalExaminerID] = " & Me.[ExternalExaminerID]
DoCmd.OpenReport "RptFees,report", acViewPreview, , strWhere
End If
End Sub
But that won't work on my popup because of 'invalid use of the me.Dirty'
I have the following code which works in the popup and brings up the report,
but brings up a report for every record instead of just the current record.
The report list comes from a query using the MsysObjects table.
Private Sub lstReports_DblClick(Cancel As Integer)
ShowReports lstReports.Value, Forms!AMainform
End Sub
Function ShowReports(strReportName As String, frm As Form) As Integer
On Error Resume Next
Dim strWhereCond As String
strWhereCond = "MyField = " & frm!MyField
DoCmd.OpenReport strReportName, acViewPreview, , strWhereCond
If Err > 0 Then
'OpenReport failed
MyFunction = False
Else
MyFunction = True
End If
Exit Function
End Function
I admit I have just copied and pasted these and taken them from other help
topics so I don't actually completely understand it all. How do I make the
single record code work in the popup? Or how do I change the popup code to
take just the record that's in the main form?
Thanks very much.