Parameters/Reports

F

Fie

hey..

What iv done is created a form to supply parameters to a report. Having
found how to do this on Microsoft site. The follwing code i added to
the form, which allows users to select customer name from combo box and
enter start and finsh dates.


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 the use of the Meal Uptake Report", vbOKOnly
Cancel = True
End If
Form_Open_Exit:
Exit Sub
End Sub

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


when i run the report the form pops up which i want it to do, but when
i click on the OK button and error comes up in the supporting code
module which is

Option Compare Database
Option Explicit

Public bInReportOpenEvent As Boolean ' Is report in the Open event?

Function IsLoaded(ByVal strMealUptake As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet
view.
Dim oAccessObject As AccessObject

Set oAccessObject = CurrentProject.AllForms(strMealUptake)
If oAccessObject.IsLoaded Then
If oAccessObject.CurrentView <> acCurViewDesign Then
IsLoaded = True
End If
End If

End Function


It does not seem to like "Function IsLoaded(ByVal FormName As String)
As Boolean"

I thought it might be something to do with "ByVal FormName As String"
and put in the name of my form instead of FormName but this does not
seem to work and works well with the example i downloaed....

can any1 help me pllllllleeeaasssee iv hut a brick wall and cant get
past it...
 
M

MGFoster

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

Are you setting the strFormName before you call the function? E.g.:

If IsLoaded("frmMealUptake") Then
....

OR

strFormName = "frmMealUptake"
If IsLoaded(strFormName) Then
....

The Function should use the parameter like this:

Public Function IsLoaded(ByVal strFormName As String) As Boolean

Dim oAccessObject As AccessObject

Set oAccessObject = CurrentProject.AllForms(strFormName)
If oAccessObject.IsLoaded Then
If oAccessObject.CurrentView <> acCurViewDesign Then
IsLoaded = True
End If
End If

End Function

HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQ+uitoechKqOuFEgEQI+7wCgruMAK6ERizQztQ64lvOQQ5r54LMAoIE8
yQufPMpSUmWCEYDPeczt0g4U
=jh22
-----END PGP SIGNATURE-----
 

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

Top