By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,828 Members | 1,862 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,828 IT Pros & Developers. It's quick & easy.

Getting the Sub or Function not defined error

P: n/a
Hi,

I'm using access 97 SR2 on win XP and keep getting the Sub or Function
not defined error message.

The code for the function is in a module called mod_Public and is as
follows.

Function IsLoaded(MyFormName As String)
' Determines if a form is loaded.

Const FORM_DESIGN = 0
Dim I As Integer

IsLoaded = False

For I = 0 To Forms.Count - 1
If Forms(I).FormName = MyFormName Then
If Forms(I).CurrentView <> FORM_DESIGN Then
IsLoaded = True
Exit Function
End If
End If
Next

End Function
I'm trying to run the module in the on close event of another form.
This code is as follows.

Private Sub Form_Close()
If IsLoaded("ERA") = True Then
Forms![ERA]![ctl_Tab]!Cmbo_BuildingId.Requery
End If

End Sub
Can anyone see what I am doing wrong?

Regards
Steve
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Do you have a space between If and IsLoaded?

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Steve Strik" <st********@hotmail.com> wrote in message
news:2e*************************@posting.google.co m...
Hi,

I'm using access 97 SR2 on win XP and keep getting the Sub or Function
not defined error message.

The code for the function is in a module called mod_Public and is as
follows.

Function IsLoaded(MyFormName As String)
' Determines if a form is loaded.

Const FORM_DESIGN = 0
Dim I As Integer

IsLoaded = False

For I = 0 To Forms.Count - 1
If Forms(I).FormName = MyFormName Then
If Forms(I).CurrentView <> FORM_DESIGN Then
IsLoaded = True
Exit Function
End If
End If
Next

End Function
I'm trying to run the module in the on close event of another form.
This code is as follows.

Private Sub Form_Close()
If IsLoaded("ERA") = True Then
Forms![ERA]![ctl_Tab]!Cmbo_BuildingId.Requery
End If

End Sub
Can anyone see what I am doing wrong?

Regards
Steve

Nov 13 '05 #2

P: n/a
Yes. As displayed.
"PC Datasheet" <no****@nospam.spam> wrote in message news:<pU*****************@newsread2.news.atl.earth link.net>...
Do you have a space between If and IsLoaded?

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Steve Strik" <st********@hotmail.com> wrote in message
news:2e*************************@posting.google.co m...
Hi,

I'm using access 97 SR2 on win XP and keep getting the Sub or Function
not defined error message.

The code for the function is in a module called mod_Public and is as
follows.

Function IsLoaded(MyFormName As String)
' Determines if a form is loaded.

Const FORM_DESIGN = 0
Dim I As Integer

IsLoaded = False

For I = 0 To Forms.Count - 1
If Forms(I).FormName = MyFormName Then
If Forms(I).CurrentView <> FORM_DESIGN Then
IsLoaded = True
Exit Function
End If
End If
Next

End Function
I'm trying to run the module in the on close event of another form.
This code is as follows.

Private Sub Form_Close()
If IsLoaded("ERA") = True Then
Forms![ERA]![ctl_Tab]!Cmbo_BuildingId.Requery
End If

End Sub
Can anyone see what I am doing wrong?

Regards
Steve

Nov 13 '05 #3

P: n/a
I found a fix.

I changed the following line in the Module and added "As Boolean" Works fine now.

Function IsLoaded(MyFormName As String) As Boolean

st********@hotmail.com (Steve Strik) wrote in message news:<2e*************************@posting.google.c om>...
Hi,

I'm using access 97 SR2 on win XP and keep getting the Sub or Function
not defined error message.

The code for the function is in a module called mod_Public and is as
follows.

Function IsLoaded(MyFormName As String)
' Determines if a form is loaded.

Const FORM_DESIGN = 0
Dim I As Integer

IsLoaded = False

For I = 0 To Forms.Count - 1
If Forms(I).FormName = MyFormName Then
If Forms(I).CurrentView <> FORM_DESIGN Then
IsLoaded = True
Exit Function
End If
End If
Next

End Function
I'm trying to run the module in the on close event of another form.
This code is as follows.

Private Sub Form_Close()
If IsLoaded("ERA") = True Then
Forms![ERA]![ctl_Tab]!Cmbo_BuildingId.Requery
End If

End Sub
Can anyone see what I am doing wrong?

Regards
Steve

Nov 13 '05 #4

P: n/a
st********@hotmail.com (Steve Strik) wrote in
news:2e**************************@posting.google.c om:
I found a fix.

I changed the following line in the Module and added "As
Boolean" Works fine now.

Function IsLoaded(MyFormName As String) As Boolean


You might also try explicitly declaring the function as public.

eg public function isloaded(....) as ...
--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #5

P: n/a
Bob Quintal wrote:
st********@hotmail.com (Steve Strik) wrote in
news:2e**************************@posting.google.c om:

I found a fix.

I changed the following line in the Module and added "As
Boolean" Works fine now.

Function IsLoaded(MyFormName As String) As Boolean

You might also try explicitly declaring the function as public.

eg public function isloaded(....) as ...

I thought Public was the default?

--

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\

Nov 13 '05 #6

P: n/a
Trevor Best <nospam@localhost> wrote in news:4135b947$0$11814
$a*******@auth.uk.news.easynet.net:
Bob Quintal wrote:

You might also try explicitly declaring the function as public.

eg public function isloaded(....) as ...

I thought Public was the default?

Like many other things in VB, it sometimes helps the compiler to
restate the obvious. :) ISTR that it was private by default in
earlier versions of MsAccess.
--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.