I am desparate, please can someone tell me how I can change a report title in an Access 2000 report from within my VB6 code?
I did something like this but it is not changing thye title
Sub PrintReport(TheReport As String, TheCriteria As String, TheHeading As String)
'------------------------- If access is open then close it --------------
On Error Resume Next
objAccess.Quit
On Error GoTo NoRecords
'------------------------- Open Database --------------------------------
Set objAccess = New Access.Application
objAccess.Visible = True
objAccess.OpenCurrentDatabase (DatabasePath)
objAccess.RunCommand acCmdAppMaximize
'------------------------- Open Report and set the Heading --------------
objAccess.DoCmd.OpenReport TheReport, acViewPreview, , TheCriteria
If TheHeading <> "" Then
objAccess.Reports(TheReport).Controls!lblHeading.Caption = TheHeading
End If
'------------------------- Set the criteria for report ------------------
If TheCriteria <> "" Then
objAccess.Reports(TheReport).Filter = TheCriteria
DoEvents
End If
objAccess.Reports(TheReport).FilterOn = True
DoEvents
objAccess.DoCmd.Maximize
objAccess.Visible = True
Exit Sub
NoRecords:
If Err.Number = 2486 Then
Resume
Else
MsgBox "There are no records that match your request.", vbExclamation, "No Records"
End If
End Sub