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