dialog box in report

strawberry

Registered User.
Local time
Today, 14:02
Joined
Apr 1, 2008
Messages
43
Hi there, i have created a report linked to a query. one of the query fields refers to a 'dialogbox' for its choices

I have added the following code in the properties of the report in the 'on open'

' 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


but when i run the report, i get the following error

compile error 'sub or function not defined' and in the coding for 'on open' it highlights 'isloaded'

Hope someone can help

Many thanks
Jane
 
Re: code to open dialog box in a report not working

IsLoaded (as you have used it) is not a native Access function. You would need the additional function in a standard module to use it that way. However, there is an IsLoaded function built-in but you access it like:

Code:
If CurrentProject.AllForms.IsLoaded("YourFormNameHere") Then ...
 
Re: code to open dialog box in a report not working

IsLoaded (as you have used it) is not a native Access function. You would need the additional function in a standard module to use it that way. However, there is an IsLoaded function built-in but you access it like:

Code:
If CurrentProject.AllForms.IsLoaded("YourFormNameHere") Then ...
thanks for your reply, i have now got the following code


'------------------------------------------------------------
' Report_Open
'
'------------------------------------------------------------
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Report_Open_Err
' open form
DoCmd.OpenForm "dialogbox", acNormal, "", "", acEdit, acDialog

If CurrentProject.AllForms.IsLoaded("dialogbox") Then

DoCmd.CancelEvent
End If

Report_Open_Exit:
Exit Sub
Report_Open_Err:
MsgBox Error$
Resume Report_Open_Exit
End Sub


when i run the report, the dialog box comes up as it should but when i choose an option i get the message 'object doesnt support this property or method'

Please help

many thanks
Jane
 
Re: code to open dialog box in a report not working

Why are you using

DoCmd.CancelEvent

???

And, what code, if any, do you have on the form?
 
Well you need to first have the IsLoaded function somewhere in a module. U might use the following one:

Function IsLoaded(ByVal strFormName As String) As Boolean
Const conObjStateClosed = 0
Const conDesignMode = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName ) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignMode Then
Loaded = True
End If
End If
End Function

Copy and save in a Module. Run your report again.

HTH
 
Please don't post duplicates.

(duplicate post reported)
 
Re: code to open dialog box in a report not working

I only have an event procedure for the open form and close form event, which opens the dialog box with the choices in it. I am using Access 2007 but i copied this code from a similar report i did in an earlier version of Access which worked fine.

the code i have is as follows
'------------------------------------------------------------
' 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

'------------------------------------------------------------
' Report_Open
'
'------------------------------------------------------------
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Report_Open_Err
' open form
DoCmd.OpenForm "dialogbox", acNormal, "", "", acEdit, acDialog

If CurrentProject.AllForms.IsLoaded("dialogbox") Then

DoCmd.CancelEvent
End If

Report_Open_Exit:
Exit Sub
Report_Open_Err:
MsgBox Error$
Resume Report_Open_Exit
End Sub


Hope this makes sense
 
Hey thanks for your reply.

I have create a module with the code you have given and run the report again, now i get message 'object doesnt support this property or method'

Basically i am trying to run a report based on a query, one of the fields is linked to 'dialog box' with the list of choices in it. i have created the query, i have created the dialog box, now i want to just put the code into the report to open and close the dialog box.

I have used the code i am currently using in previous databases (pre 2007) and all works fine. Now i am working in access 2007, does this make a difference

Many thanks
 
Ok, check the line that says "Loaded = True" and change it to: IsLoaded = True. Mea Culpa.

HTH

By the way, Bob, I don't get what u mean by duplicated post: is it my post or Strawberry's?
 
sorry,i thought that as i had no replies when i asked the question to reports forum i had posted it to the wrong forum so i resent it again to the vba forum

apologies
 

Users who are viewing this thread

Back
Top Bottom