Getting the Sub or Function not defined error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Strik

    Getting the Sub or Function not defined error

    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(MyForm Name 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).FormNa me = MyFormName Then
    If Forms(I).Curren tView <> 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_BuildingI d.Requery
    End If

    End Sub


    Can anyone see what I am doing wrong?

    Regards


    Steve
  • PC Datasheet

    #2
    Re: Getting the Sub or Function not defined error

    Do you have a space between If and IsLoaded?

    --
    PC Datasheet
    Your Resource For Help With Access, Excel And Word Applications
    resource@pcdata sheet.com



    "Steve Strik" <stevestrik@hot mail.com> wrote in message
    news:2ea8f6f7.0 408301701.ac231 6c@posting.goog le.com...[color=blue]
    > 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(MyForm Name 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).FormNa me = MyFormName Then
    > If Forms(I).Curren tView <> 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_BuildingI d.Requery
    > End If
    >
    > End Sub
    >
    >
    > Can anyone see what I am doing wrong?
    >
    > Regards
    >
    >
    > Steve[/color]


    Comment

    • Steve Strik

      #3
      Re: Getting the Sub or Function not defined error

      Yes. As displayed.


      "PC Datasheet" <nospam@nospam. spam> wrote in message news:<pUQYc.889 6$6o3.7993@news read2.news.atl. earthlink.net>. ..[color=blue]
      > Do you have a space between If and IsLoaded?
      >
      > --
      > PC Datasheet
      > Your Resource For Help With Access, Excel And Word Applications
      > resource@pcdata sheet.com
      > www.pcdatasheet.com
      >
      >
      > "Steve Strik" <stevestrik@hot mail.com> wrote in message
      > news:2ea8f6f7.0 408301701.ac231 6c@posting.goog le.com...[color=green]
      > > 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(MyForm Name 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).FormNa me = MyFormName Then
      > > If Forms(I).Curren tView <> 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_BuildingI d.Requery
      > > End If
      > >
      > > End Sub
      > >
      > >
      > > Can anyone see what I am doing wrong?
      > >
      > > Regards
      > >
      > >
      > > Steve[/color][/color]

      Comment

      • Steve Strik

        #4
        Re: Getting the Sub or Function not defined error

        I found a fix.

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

        Function IsLoaded(MyForm Name As String) As Boolean

        stevestrik@hotm ail.com (Steve Strik) wrote in message news:<2ea8f6f7. 0408301701.ac23 16c@posting.goo gle.com>...[color=blue]
        > 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(MyForm Name 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).FormNa me = MyFormName Then
        > If Forms(I).Curren tView <> 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_BuildingI d.Requery
        > End If
        >
        > End Sub
        >
        >
        > Can anyone see what I am doing wrong?
        >
        > Regards
        >
        >
        > Steve[/color]

        Comment

        • Bob Quintal

          #5
          Re: Getting the Sub or Function not defined error

          stevestrik@hotm ail.com (Steve Strik) wrote in
          news:2ea8f6f7.0 408302356.6e73c 622@posting.goo gle.com:
          [color=blue]
          > I found a fix.
          >
          > I changed the following line in the Module and added "As
          > Boolean" Works fine now.
          >
          > Function IsLoaded(MyForm Name As String) As Boolean
          >[/color]

          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.

          Comment

          • Trevor Best

            #6
            Re: Getting the Sub or Function not defined error

            Bob Quintal wrote:
            [color=blue]
            > stevestrik@hotm ail.com (Steve Strik) wrote in
            > news:2ea8f6f7.0 408302356.6e73c 622@posting.goo gle.com:
            >
            >[color=green]
            >>I found a fix.
            >>
            >>I changed the following line in the Module and added "As
            >>Boolean" Works fine now.
            >>
            >>Function IsLoaded(MyForm Name As String) As Boolean
            >>[/color]
            >
            >
            > You might also try explicitly declaring the function as public.
            >
            > eg public function isloaded(....) as ...
            >
            >[/color]
            I thought Public was the default?

            --

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

            Comment

            • Bob Quintal

              #7
              Re: Getting the Sub or Function not defined error

              Trevor Best <nospam@localho st> wrote in news:4135b947$0 $11814
              $afc38c87@auth. uk.news.easynet .net:
              [color=blue]
              > Bob Quintal wrote:
              >[color=green]
              >>
              >> You might also try explicitly declaring the function as public.
              >>
              >> eg public function isloaded(....) as ...
              >>
              >>[/color]
              > I thought Public was the default?
              >[/color]
              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.

              Comment

              Working...