Error: User-Defined Type Not Defined

Error: User-Defined Type Not Defined

Post by Earl Ander » Tue, 17 Feb 2004 11:10:49


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
 
 
 

Error: User-Defined Type Not Defined

Post by Allen Brow » Tue, 17 Feb 2004 11:34:22

Try MDAC 2.5:
http://www.yqcomputer.com/
2.7 does not include the JET drivers IIRC.

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



I'm

 
 
 

Error: User-Defined Type Not Defined

Post by Earl Ander » Tue, 17 Feb 2004 22:13:13

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





"User-defined
one
 
 
 

Error: User-Defined Type Not Defined

Post by rkc » Tue, 17 Feb 2004 22:51:53


same
be
there

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?
 
 
 

Error: User-Defined Type Not Defined

Post by Earl Ander » Wed, 18 Feb 2004 01:15:41

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





Installed
but
 
 
 

Error: User-Defined Type Not Defined

Post by David W. F » Wed, 18 Feb 2004 03:36:32

"Earl Anderson" < XXXX@XXXXX.COM > wrote in



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

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

Error: User-Defined Type Not Defined

Post by rkc » Wed, 18 Feb 2004 04:43:10


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.