Multiuser Custom Counter Not Working

D

Darren

I'm trying to get the code from the KB article #210194 to
work. Creating a Custom Counter.
http://support.microsoft.com/default.aspx?scid=kb;en-us;210194

As far as I can tell my code and actions are identical to
the article. However when I click on the form I get an
Error: 3265 msg. This error appears to be due to an object
being referenced before it is in the library? (link -
http://support.microsoft.com/default.aspx?scid=kb;en-us;223212)

Here is my code which compiles fine:
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

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

MsgBox "Next Available Counter is " & Str(NextCounter)

rs.Close

Set rs = Nothing

Next_Custom_Counter = NextCounter

Exit Function

Any suggestions?
 
J

John Vinson

As far as I can tell my code and actions are identical to
the article. However when I click on the form I get an
Error: 3265 msg. This error appears to be due to an object
being referenced before it is in the library? (link -
http://support.microsoft.com/default.aspx?scid=kb;en-us;223212)

I suspect that you're using A2000 or later, which default to using the
ADO Object Model instead of the DAO object model required by this
code.

Open the VBA editor and select Tools... References. Uncheck "Microsoft
ActiveX Data Objects" unless you know you'll be using ADOX references;
scroll down and find Microsoft DAO x.xx Object Library (highest
version) and check it instead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top