Help with basic Macro

Carey27

Registered User.
Local time
Today, 17:36
Joined
Jul 20, 2010
Messages
10
Im working at a non-profit clinic for the summer and have been tasked with updating their DB. Years ago i worked with access and have been able to build the tables, queries, forms, switchboards etc... but have been running into problems adding bells and whistles that require VBA.

I followed the guide posted on the link below to build a form that gathers a start and end date and then passes them to a query I built.

http://office.microsoft.com/en-ca/access-help/use-parameters-in-queries-and-reports-HA010096314.aspx

I receive the following VBA error when running a module that checks to see if I have the query open already....
"Compile Error: Expected End Function"
The code i used is:

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

Any help will be appreciated. I dont really understand VBA so Im not sure if I have provided all the info you'd need to help. Just let me know and I will provide it.

Thanks,
 
The error means you need to add the line in red:
Code:
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
[B][COLOR="Red"]End Function[/COLOR][/B]
 
The error means you need to add the line in red:
Code:
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
[B][COLOR=Red]End Function[/COLOR][/B]
That wasn't even on the link:eek:
 
Or using your priviledges you could simply log into their database and make the change yourself? :)
 
Or using your priviledges you could simply log into their database and make the change yourself? :)

What privileges? I have none. Neither does any current MVP (let alone Former ones like me). All any of them, or I, can do is to make suggestions to them and hope that they take them. A lot of the time they do NOT take the suggestions, or corrections. :)
 
Thanks guys, its running smoothly now (Amazing how quick you replied).

Kind of embarrassed how simple that was, but glad MS had it wrong on their site. Thanks again.
 
Hi Carey,

Thanks for pointing this issue out. The article is indeed missing the End Function line in the sample.

I discussed this with our Help content people and they have already corrected the issue. The new article will be published soon.

Thanks for the feedback.

--------------------
Jeff Conrad - Access Junkie - MVP Alumnus
SDET II - Access Test Team - Microsoft Corporation

Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010 Info: http://www.AccessJunkie.com

----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
 

Users who are viewing this thread

Back
Top Bottom