Error: User-Defined Type Not Defined

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Earl Anderson

    Error: User-Defined Type Not Defined

    In A97 on WinXP, I'm trying to use a KB function to provide the next
    sequential number in a custom counter (a table with two fields--
    [NextAvailable] and [FromYear] ). When I run it, I get the "User-defined
    type not defined" error on the third line of code (Dim rs As
    ADODB.Recordset ) I'm using below:

    " Function Next_Custom_Cou nter()
    On Error GoTo Next_Custom_Cou nter_Err

    Dim rs As ADODB.Recordset
    Dim NextCounter As Long
    Set rs = New ADODB.Recordset
    rs.Open "CounterTab le", CurrentProject. Connection, adOpenKeyset,
    adLockOptimisti c

    NextCounter = rs!NextAvailabl eCounter
    If rs!FromYear < Year(Date) Then
    rs!FromYear = Year(Date)
    NextCounter = 0
    End If

    rs!NextAvailabl eCounter = NextCounter + 1
    NextCounter = rs!NextAvailabl eCounter
    rs.Update

    MsgBox "Next available counter value is " & Str(NextCounter )

    rs.Close

    Set rs = Nothing

    Next_Custom_Cou nter = NextCounter

    Exit Function
    Next_Custom_Cou nter_Err:
    MsgBox "Error " & Err & ": " & Error$
    If Err <> 0 Then Resume
    End
    End Function "

    I know this has been asked and answered "1000 times", but I did check my
    references which are:

    Visual Basic for Applications
    Microsoft Access 8.0 Object Library
    Microsoft ADO Ext. 2.7 for DLL and Security
    Microsoft DAO 3.6 Object Library
    Microsoft ActiveX Data Object Recordset 2.7 Library

    I read the 'Help' file and the 'Reference' issue seemed to be the only one
    of the three that was applicable to this code. Is there another reason I'm
    getting this error or am I missing something regarding my References?

    Thx for any help.
    Earl





  • Allen Browne

    #2
    Re: Error: User-Defined Type Not Defined

    Try MDAC 2.5:

    2.7 does not include the JET drivers IIRC.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Earl Anderson" <isobadd@rcn.co m> wrote in message
    news:403026aa$0 $3099$61fed72c@ news.rcn.com...[color=blue]
    > In A97 on WinXP, I'm trying to use a KB function to provide the next
    > sequential number in a custom counter (a table with two fields--
    > [NextAvailable] and [FromYear] ). When I run it, I get the "User-defined
    > type not defined" error on the third line of code (Dim rs As
    > ADODB.Recordset ) I'm using below:
    >
    > " Function Next_Custom_Cou nter()
    > On Error GoTo Next_Custom_Cou nter_Err
    >
    > Dim rs As ADODB.Recordset
    > Dim NextCounter As Long
    > Set rs = New ADODB.Recordset
    > rs.Open "CounterTab le", CurrentProject. Connection, adOpenKeyset,
    > adLockOptimisti c
    >
    > NextCounter = rs!NextAvailabl eCounter
    > If rs!FromYear < Year(Date) Then
    > rs!FromYear = Year(Date)
    > NextCounter = 0
    > End If
    >
    > rs!NextAvailabl eCounter = NextCounter + 1
    > NextCounter = rs!NextAvailabl eCounter
    > rs.Update
    >
    > MsgBox "Next available counter value is " & Str(NextCounter )
    >
    > rs.Close
    >
    > Set rs = Nothing
    >
    > Next_Custom_Cou nter = NextCounter
    >
    > Exit Function
    > Next_Custom_Cou nter_Err:
    > MsgBox "Error " & Err & ": " & Error$
    > If Err <> 0 Then Resume
    > End
    > End Function "
    >
    > I know this has been asked and answered "1000 times", but I did check my
    > references which are:
    >
    > Visual Basic for Applications
    > Microsoft Access 8.0 Object Library
    > Microsoft ADO Ext. 2.7 for DLL and Security
    > Microsoft DAO 3.6 Object Library
    > Microsoft ActiveX Data Object Recordset 2.7 Library
    >
    > I read the 'Help' file and the 'Reference' issue seemed to be the only one
    > of the three that was applicable to this code. Is there another reason[/color]
    I'm[color=blue]
    > getting this error or am I missing something regarding my References?
    >
    > Thx for any help.
    > Earl[/color]


    Comment

    • Earl Anderson

      #3
      Re: Error: User-Defined Type Not Defined

      Went to 'References', checked "Microsoft Data Access Components Installed
      Version", to include it with the other 5 checked references -- no luck; same
      compile error. I went to the Microsoft site and tried to download it, but
      installation was halted because it was "already installed". Could there be
      a conflict between any of the 6 References? Short of starting over, is there
      anything else I should be looking at/for in the References or code?

      Thx...
      Earl

      "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote in message
      news:40302c31$0 $1724$5a62ac22@ freenews.iinet. net.au...[color=blue]
      > Try MDAC 2.5:
      > http://support.microsoft.com/default.aspx?kbid=293312
      > 2.7 does not include the JET drivers IIRC.
      >
      > --
      > Allen Browne - Microsoft MVP. Perth, Western Australia.
      > Tips for Access users - http://allenbrowne.com/tips.html
      > Reply to group, rather than allenbrowne at mvps dot org.
      >
      > "Earl Anderson" <isobadd@rcn.co m> wrote in message
      > news:403026aa$0 $3099$61fed72c@ news.rcn.com...[color=green]
      > > In A97 on WinXP, I'm trying to use a KB function to provide the next
      > > sequential number in a custom counter (a table with two fields--
      > > [NextAvailable] and [FromYear] ). When I run it, I get the[/color][/color]
      "User-defined[color=blue][color=green]
      > > type not defined" error on the third line of code (Dim rs As
      > > ADODB.Recordset ) I'm using below:
      > >
      > > " Function Next_Custom_Cou nter()
      > > On Error GoTo Next_Custom_Cou nter_Err
      > >
      > > Dim rs As ADODB.Recordset
      > > Dim NextCounter As Long
      > > Set rs = New ADODB.Recordset
      > > rs.Open "CounterTab le", CurrentProject. Connection, adOpenKeyset,
      > > adLockOptimisti c
      > >
      > > NextCounter = rs!NextAvailabl eCounter
      > > If rs!FromYear < Year(Date) Then
      > > rs!FromYear = Year(Date)
      > > NextCounter = 0
      > > End If
      > >
      > > rs!NextAvailabl eCounter = NextCounter + 1
      > > NextCounter = rs!NextAvailabl eCounter
      > > rs.Update
      > >
      > > MsgBox "Next available counter value is " & Str(NextCounter )
      > >
      > > rs.Close
      > >
      > > Set rs = Nothing
      > >
      > > Next_Custom_Cou nter = NextCounter
      > >
      > > Exit Function
      > > Next_Custom_Cou nter_Err:
      > > MsgBox "Error " & Err & ": " & Error$
      > > If Err <> 0 Then Resume
      > > End
      > > End Function "
      > >
      > > I know this has been asked and answered "1000 times", but I did check my
      > > references which are:
      > >
      > > Visual Basic for Applications
      > > Microsoft Access 8.0 Object Library
      > > Microsoft ADO Ext. 2.7 for DLL and Security
      > > Microsoft DAO 3.6 Object Library
      > > Microsoft ActiveX Data Object Recordset 2.7 Library
      > >
      > > I read the 'Help' file and the 'Reference' issue seemed to be the only[/color][/color]
      one[color=blue][color=green]
      > > of the three that was applicable to this code. Is there another reason[/color]
      > I'm[color=green]
      > > getting this error or am I missing something regarding my References?
      > >
      > > Thx for any help.
      > > Earl[/color]
      >
      >[/color]


      Comment

      • rkc

        #4
        Re: Error: User-Defined Type Not Defined


        "Earl Anderson" <isobadd@rcn.co m> wrote in message
        news:4030c1f1$0 $3076$61fed72c@ news.rcn.com...[color=blue]
        > Went to 'References', checked "Microsoft Data Access Components Installed
        > Version", to include it with the other 5 checked references -- no luck;[/color]
        same[color=blue]
        > compile error. I went to the Microsoft site and tried to download it, but
        > installation was halted because it was "already installed". Could there[/color]
        be[color=blue]
        > a conflict between any of the 6 References? Short of starting over, is[/color]
        there[color=blue]
        > anything else I should be looking at/for in the References or code?[/color]

        Try unchecking
        "Microsoft ActiveX Data Object Recordset 2.7 Library"
        and checking
        "Microsoft ActiveX Data Object 2.7 Library"

        Aren't you going to have problems when you get to the line

        rs.Open "CounterTab le", CurrentProject. Connection, adOpenKeyset...

        in an Access 97 application? CurrentProject?









        Comment

        • Earl Anderson

          #5
          Re: Error: User-Defined Type Not Defined

          That took care of the "User-defined type not defined" error and yes, I did
          get the error on 'CurrentProject ' and declared that also.

          Thanks to both you and Allen.
          Earl

          "rkc" <rkc@yabba.dabb a.do.rochester. rr.bomb> wrote in message
          news:ZV3Yb.7274 7$%72.17447@twi ster.nyroc.rr.c om...[color=blue]
          >
          > "Earl Anderson" <isobadd@rcn.co m> wrote in message
          > news:4030c1f1$0 $3076$61fed72c@ news.rcn.com...[color=green]
          > > Went to 'References', checked "Microsoft Data Access Components[/color][/color]
          Installed[color=blue][color=green]
          > > Version", to include it with the other 5 checked references -- no luck;[/color]
          > same[color=green]
          > > compile error. I went to the Microsoft site and tried to download it,[/color][/color]
          but[color=blue][color=green]
          > > installation was halted because it was "already installed". Could there[/color]
          > be[color=green]
          > > a conflict between any of the 6 References? Short of starting over, is[/color]
          > there[color=green]
          > > anything else I should be looking at/for in the References or code?[/color]
          >
          > Try unchecking
          > "Microsoft ActiveX Data Object Recordset 2.7 Library"
          > and checking
          > "Microsoft ActiveX Data Object 2.7 Library"
          >
          > Aren't you going to have problems when you get to the line
          >
          > rs.Open "CounterTab le", CurrentProject. Connection, adOpenKeyset...
          >
          > in an Access 97 application? CurrentProject?
          >
          >
          >
          >
          >
          >
          >
          >
          >[/color]


          Comment

          • David W. Fenton

            #6
            Re: Error: User-Defined Type Not Defined

            "Earl Anderson" <isobadd@rcn.co m> wrote in
            news:4030ecb5$0 $3091$61fed72c@ news.rcn.com:
            [color=blue]
            > That took care of the "User-defined type not defined" error and
            > yes, I did get the error on 'CurrentProject ' and declared that
            > also.[/color]

            May I ask why you're using ADO in A97?

            --
            David W. Fenton http://www.bway.net/~dfenton
            dfenton at bway dot net http://www.bway.net/~dfassoc

            Comment

            • rkc

              #7
              Re: Error: User-Defined Type Not Defined


              "Earl Anderson" <isobadd@rcn.co m> wrote in message
              news:4030ecb5$0 $3091$61fed72c@ news.rcn.com...[color=blue]
              > That took care of the "User-defined type not defined" error and yes, I did
              > get the error on 'CurrentProject ' and declared that also.[/color]

              So the function is working now?
              The problem is that there is no CurrentProject in an A97 application.
              Your solution is probably to re-write the function you found so that
              it uses DAO in place of ADO.


              Comment

              Working...