472,145 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

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_Counter()
On Error GoTo Next_Custom_Counter_Err

Dim rs As ADODB.Recordset
Dim NextCounter As Long
Set rs = New ADODB.Recordset
rs.Open "CounterTable", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

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

rs!NextAvailableCounter = NextCounter + 1
NextCounter = rs!NextAvailableCounter
rs.Update

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

rs.Close

Set rs = Nothing

Next_Custom_Counter = NextCounter

Exit Function
Next_Custom_Counter_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

Nov 12 '05 #1
6 12640
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" <is*****@rcn.com> wrote in message
news:40**********************@news.rcn.com...
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_Counter()
On Error GoTo Next_Custom_Counter_Err

Dim rs As ADODB.Recordset
Dim NextCounter As Long
Set rs = New ADODB.Recordset
rs.Open "CounterTable", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

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

rs!NextAvailableCounter = NextCounter + 1
NextCounter = rs!NextAvailableCounter
rs.Update

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

rs.Close

Set rs = Nothing

Next_Custom_Counter = NextCounter

Exit Function
Next_Custom_Counter_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

Nov 12 '05 #2
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" <Al*********@SeeSig.Invalid> wrote in message
news:40**********************@freenews.iinet.net.a u...
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" <is*****@rcn.com> wrote in message
news:40**********************@news.rcn.com...
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_Counter()
On Error GoTo Next_Custom_Counter_Err

Dim rs As ADODB.Recordset
Dim NextCounter As Long
Set rs = New ADODB.Recordset
rs.Open "CounterTable", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

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

rs!NextAvailableCounter = NextCounter + 1
NextCounter = rs!NextAvailableCounter
rs.Update

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

rs.Close

Set rs = Nothing

Next_Custom_Counter = NextCounter

Exit Function
Next_Custom_Counter_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


Nov 12 '05 #3
rkc

"Earl Anderson" <is*****@rcn.com> wrote in message
news:40**********************@news.rcn.com...
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?


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 "CounterTable", CurrentProject.Connection, adOpenKeyset...

in an Access 97 application? CurrentProject?



Nov 12 '05 #4
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" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in message
news:ZV*******************@twister.nyroc.rr.com...

"Earl Anderson" <is*****@rcn.com> wrote in message
news:40**********************@news.rcn.com...
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?


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 "CounterTable", CurrentProject.Connection, adOpenKeyset...

in an Access 97 application? CurrentProject?



Nov 12 '05 #5
"Earl Anderson" <is*****@rcn.com> wrote in
news:40**********************@news.rcn.com:
That took care of the "User-defined type not defined" error and
yes, I did get the error on 'CurrentProject' and declared that
also.


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
Nov 12 '05 #6
rkc

"Earl Anderson" <is*****@rcn.com> wrote in message
news:40**********************@news.rcn.com...
That took care of the "User-defined type not defined" error and yes, I did
get the error on 'CurrentProject' and declared that also.


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.
Nov 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Brian Conway | last post: by
2 posts views Thread by Nigel Frost | last post: by
5 posts views Thread by Martin Robins | last post: by
6 posts views Thread by John Lau | last post: by
13 posts views Thread by Edward Mitchell | last post: by
2 posts views Thread by hansiman | last post: by
2 posts views Thread by jthep | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.