Invalid keyword - New connection

s0rtd

Registered User.
Local time
Today, 23:14
Joined
Apr 16, 2003
Messages
96
Hi guys, i have a bit of a problem here, my dbase has been working for ages!, and now all of a sudden i get this error: "invalid use of New keyword"

when this code is executed:
Code:
Dim aConn As Connection
    Dim aRecordset As Recordset
    
    Set aConn = New Connection
    aConn.Open "DSN=Prospect"
    Set aRecordset = New Recordset
    
    aRecordset.Open _
        Source:="Select max([our order number]) as nextorder from orders", _
        ActiveConnection:=aConn, _
        CursorType:=adOpenStatic, _
        LockType:=adLockReadOnly
        
    aRecordset.MoveFirst
    
    Me.Our_Order_Number.SetFocus
    Me.Our_Order_Number.Text = aRecordset!nextorder + 1
    
    Set aRecordset = Nothing
    Set aConn = Nothing

it stops at this line: "Set aConn = New Connection"

i hope someone know why it is doing this??

cheers
Jurgen
 
Check your references and make sure that you still have an ADO reference. It may be missing or broken.

Also make sure that you don't have any other missing or broken references as these sometimes cause issues with the native commands of VBA.
 
ok, i thought that may have something to do with it; a couple of question, my dbase is split into a backend and a frontend, should i be checking the refrences on the backend (sounds like a stupid question, but i want to be certain) also how do i know if i have a broken reference, and what is the ADO reference called?

cheers
Jurgen
 
You will only need to check the references on the MDB file that runs the code. Most of the time this is only the Front End (FE).

You will know that you have a broken/missing reference when you goto the code view, Tools, References and see the words Broken or Missing on the selected reference. Also keep in mind that sometimes It does not show, but you will still need to remove and then add a reference to refresh the reference list.


The ADO reference is called Microsoft ActiveX Data Objects 2.x Library
 
I have checked the references on both the Back end and the front end, and they all appear to be good. Also there are about 20 people who use this dbase, each running a front-end, and everyone appears to have this problem. ?

im running out of ideas fast! Is there a limit to how many dao/ado connections and recordsets you can open??

is there any way i can re-write that code so i can by-pass the error?? (i know thats getting rather dirty!, but i really dont know why this problem has occurred all of a sudden)

cheers
Jurgen
 
Last edited:
References are Machine Specific. It may be that a new ADO driver has overwriten the current one (Such as a new app being installed that over rights even newer versions of the DLL)

To the version of ADO being used not being installed on PC.
 

Users who are viewing this thread

Back
Top Bottom