Trouble Using VBA with Access 2000

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am unable to issue any function within VBA and return a result in Access 2000. The simplest code fails

Dim dbCurrent as Databas
Set dbCurrent = CurrentD

The DAO and VBA references are turned on, the code compiles, but dbCurrent returns 'Nothing'. I am wondering what simple set up I might be missing to enable VBA. I have tried other functions and methods and no object seems to work. I have tried these commands under Windows 98 as well as Windows XP and both fail in the same manner. Any help is appreciated.
 
I would try explictly stating DAO in your database reference. Such that:

Dim dbCurrent as DAO.Database
Set dbCurrent = CurrentDB()

HTH

--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Scott Snider said:
I am unable to issue any function within VBA and return a result in Access 2000. The simplest code fails:

Dim dbCurrent as Database
Set dbCurrent = CurrentDb

The DAO and VBA references are turned on, the code compiles, but dbCurrent
returns 'Nothing'. I am wondering what simple set up I might be missing to
enable VBA. I have tried other functions and methods and no object seems to
work. I have tried these commands under Windows 98 as well as Windows XP
and both fail in the same manner. Any help is appreciated.
 
Scott Snider said:
I am unable to issue any function within VBA and return a result in
Access 2000. The simplest code fails:

Dim dbCurrent as Database
Set dbCurrent = CurrentDb

The DAO and VBA references are turned on, the code compiles, but
dbCurrent returns 'Nothing'. I am wondering what simple set up I
might be missing to enable VBA. I have tried other functions and
methods and no object seems to work. I have tried these commands
under Windows 98 as well as Windows XP and both fail in the same
manner. Any help is appreciated.

First question: are you working in an MDB file, or an ADP? In an ADP
(Access Data Project), CurrentDb will always return Nothing, because
there is no associated Jet database. For ADPs, the equivalent is
CurrentProject.Connection (or CurrentProject.AccessConnection -- I'm not
sure what the distinction is between them).

Second question: if you're not using an ADP, then what do you get if
you enter this in the Immediate Window:

?CurrentDb.Name
 
I am unable to issue any function within VBA and return a result in Access 2000. The simplest code fails:

Dim dbCurrent as Database
Set dbCurrent = CurrentDb

The DAO and VBA references are turned on, the code compiles, but dbCurrent returns 'Nothing'. I am wondering what simple set up I might be missing to enable VBA. I have tried other functions and methods and no object seems to work. I have tried these commands under Windows 98 as well as Windows XP and both fail in the same manner. Any help is appreciated.

Check Tools... References in the VBA editor. A2000 and A2002 do NOT
automatically include the DAO object library, linking to the ADO
(ActiveX Data Objects) library instead. If you're not using ADO,
uncheck it and scroll down to Microsoft DAO x.xx Object Library
(highest version) and check it.
 
It sounds like you've done all correctly.
Try adding the "Microsoft Access Object Library" referance
-----Original Message-----
I am unable to issue any function within VBA and return a
result in Access 2000. The simplest code fails:
Dim dbCurrent as Database
Set dbCurrent = CurrentDb

The DAO and VBA references are turned on, the code
compiles, but dbCurrent returns 'Nothing'. I am wondering
what simple set up I might be missing to enable VBA. I
have tried other functions and methods and no object seems
to work. I have tried these commands under Windows 98 as
well as Windows XP and both fail in the same manner. Any
help is appreciated.
 
Back
Top