Hi, i have previously done this in earlier versions of Access and it has worked fine but now i am using Access 2007 it doesnt work

This is what i am trying to do.

Create a report and in the underlying query one of the fields relates to a dialog box. Previously i have put in code in the report properties 'on open' and 'on close' to load up the dialog box. The code i am using is shown below but it now errors saying 'illegal function'

'------------------------------------------------------------
' Report_Open
'
'------------------------------------------------------------
Private Sub Report_Open(Cancel As Integer)


On Error GoTo Report_Open_Err

' open form
DoCmd.OpenForm "dialogbox", acNormal, "", "", acEdit, acDialog
If (Not IsLoaded("dialogbox")) Then
DoCmd.CancelEvent
End If


Report_Open_Exit:
Exit Sub

Report_Open_Err:
MsgBox Error$
Resume Report_Open_Exit

End Sub

'------------------------------------------------------------
' Report_Close
'
'------------------------------------------------------------
Private Sub Report_Close()
On Error GoTo Report_Close_Err

' close form
DoCmd.Close acForm, "dialogbox"


Report_Close_Exit:
Exit Sub

Report_Close_Err:
MsgBox Error$
Resume Report_Close_Exit



End Sub

Please can you help me fix the code so it works in Access 2007

Many thanks
Jane