Access 97 Module Code

F

Fie

What am trying to do it get my form to Pass parameters to report...
when i click on the report my form opens up and allows me to enter in
start adn end date. When I click on OK or Cancel there seems to be an
error in the module code is done seem to like

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed then

i think there must be an error cause this code is in red... can any1
help???
the code that i have is

Option Compare Database
Option Explicit

Public Function IsFormLoaded(strFormName As String) As Boolean
'John Spencer UMBC-CHPDM
'Last Update: April 7, 2000
'Purpose: Returns True if the specified form is open in Form view or



Const conObjStateClosed = 0
Const conDesignView = 0


If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed then
If Forms(strFormName).CurrentView <> conDesignView Then
IsFormLoaded = True
End If
End If


End Function
 
M

MGFoster

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Not knowing if you allowed for line wrap in your post: Have you
included the line continuation mark in the VBA code. E.g.:

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> _
conObjStateClosed Then

Note the underscore character after the not equal sign at the end of the
IF line.

I've used this successfully:

isLoaded = SysCmd(acSysCmdGetObjectState, acForm, _
strFormName) = acObjStateOpen

I don't check if the form is in design view 'cuz I don't allow users to
open form's in design view.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ+zghoechKqOuFEgEQIK4wCg4BvxYuKApSGcdOl0yCi/ueNM4CwAoPdM
OzOuJsIE5z9pd2zkgYbpUoWu
=F71c
-----END PGP SIGNATURE-----
 
S

SteveS

Why do you think you need the IsLoaded() function?

I threw together a table, form and report. I was able to get everything to
work (without the IsLoaded() function). It is backward from what I've done
in the past; normally I open the form, then open the report using a button
after I enter the parameters.

So here is what I did:

In a standard module I pasted this (for a global variable):

Public bInReportOpenEvent As Boolean


The code behind the Form "Sales By Category Dialog":
'---------------------------------
Option Compare Database
Option Explicit

Private Sub Cancel_Click()
DoCmd.Close
End Sub

Private Sub Form_Open(Cancel As Integer)
If Not bInReportOpenEvent Then
' If we're not called from the report
MsgBox "For use from the Sales By Category Report only", vbOKOnly
Cancel = True
End If

End Sub

Private Sub OK_Click()
Me.Visible = False
End Sub

Private Sub Form_close()
bInReportOpenEvent = False
End Sub



And the code behind the Report:
'----------------------------------
Option Compare Database
Option Explicit

Private Sub Report_Close()
DoCmd.Close acForm, "Sales By Category Dialog"
End Sub

Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event
bInReportOpenEvent = True

' Open Sales By Category Dialog
DoCmd.OpenForm "Sales By Category Dialog", , , , , acDialog

' Cancel Report if User Clicked the Cancel Button
' If IsLoaded("Sales By Category Dialog") = False Then Cancel = True

' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub


In the example code you provided, there is not a way (button) to cancel the
report.

You still need to add controls for the parameters and to change the queries
to reference this form for the parameters.


HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Function Name problem 5
Return without GoSub? 3
Problem checking if form is open 2
Module mystery 2
HELP 6
On Close () 0
Compile Error: Variable Not Defined 2
isloaded help. 2

Top