Group:  Microsoft Access ยป microsoft.public.access.modulescoding
Thread: Code in Visual Basic

Code in Visual Basic
Bernie 12/2/2008 2:59:02 PM
Hope this is the right group to post this in. I copied a macro from one
workbook to another which draws data from an access database to a worksheet
in Excel. Everything looked right until I ran the macro. I got a compile
error and the line that was highlighted is below:

Dim cnn As New ADODB.Connection

What does this mean? How do I fix it?


Re: Code in Visual Basic
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 12/2/2008 3:07:47 PM
If that line is causing a compile error, odds are that a reference has not
been set to ADO.

While in the VB Editor, select Tools | References from the menu bar. Scroll
through the list of available references until you find the one for
Microsoft ActiveX Data Objects 2.n Library (n will be something between 0
and 8). Select one of them (2.5 is probably a good choice).

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Bernie" <Bernie[ at ]discussions.microsoft.com> wrote in message
news:7CD88EB7-C83A-4B13-B8D8-D36DE86647F9[ at ]microsoft.com...
[Quoted Text]
> Hope this is the right group to post this in. I copied a macro from one
> workbook to another which draws data from an access database to a
> worksheet
> in Excel. Everything looked right until I ran the macro. I got a compile
> error and the line that was highlighted is below:
>
> Dim cnn As New ADODB.Connection
>
> What does this mean? How do I fix it?
>
>


Re: Code in Visual Basic
Stefan Hoffmann <ste5an[ at ]ste5an.de> 12/2/2008 3:11:22 PM
hi Bernie,

Bernie wrote:
[Quoted Text]
> Everything looked right until I ran the macro. I got a compile
> error and the line that was highlighted is below:
>
> Dim cnn As New ADODB.Connection
>
> What does this mean? How do I fix it?
You need a reference to the ADODB library. Add the appropriate MS
ActiveX Data Objects library in the VBA IDE under Tools\References.



mfG
--> stefan <--
Re: Code in Visual Basic
Bernie 12/2/2008 3:39:01 PM
Isn't allowing me to choose References

"Douglas J. Steele" wrote:

[Quoted Text]
> If that line is causing a compile error, odds are that a reference has not
> been set to ADO.
>
> While in the VB Editor, select Tools | References from the menu bar. Scroll
> through the list of available references until you find the one for
> Microsoft ActiveX Data Objects 2.n Library (n will be something between 0
> and 8). Select one of them (2.5 is probably a good choice).
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Bernie" <Bernie[ at ]discussions.microsoft.com> wrote in message
> news:7CD88EB7-C83A-4B13-B8D8-D36DE86647F9[ at ]microsoft.com...
> > Hope this is the right group to post this in. I copied a macro from one
> > workbook to another which draws data from an access database to a
> > worksheet
> > in Excel. Everything looked right until I ran the macro. I got a compile
> > error and the line that was highlighted is below:
> >
> > Dim cnn As New ADODB.Connection
> >
> > What does this mean? How do I fix it?
> >
> >
>
>
>
Re: Code in Visual Basic
Stefan Hoffmann <ste5an[ at ]ste5an.de> 12/2/2008 3:44:06 PM
hi Bernie,

Bernie wrote:
[Quoted Text]
> Isn't allowing me to choose References
You need to stop the execution of your macro, or set the reference
before even running it.


mfG
--> stefan <--

Home | Search | Terms | Imprint
Newsgroups Reader