Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 19th, 2006, 11:19 PM
Registered User
 
Join Date: Feb 2006
Location: Pinehurst, NC, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default "Compiler Options" Question (Newbie-Type)

I'm relatively new to Access and have never done VBA before. But my needs are not complex so I wasn't anticipating serious difficulties and the Wrox Access 2003 VBA Programmer's Reference seemed more than adequate for my needs.

I've built a test database just to get the basics working (doing some additional processing on data that comes from a query and gets returned to a form) and that went well.

But when I started to work in my existing database I find that VBA no longer recognizes much of anything related to databases. Specifically the following will not compile.



Option Compare Database
Option Explicit

Private Sub TestIt()
Dim qName As String
Dim dbs As Database

Debug.Print "Got to here"

End Sub

Compilation fails on the Dim dbs statement as the compiler thinks that it is a user-defined type (not defined hence the failure). I also noticed that when I type the 'Dim dbs as ..' statement the VBA editor pulldown does NOT contain 'Database'. It is like I have issued some kind of "Database Off" compiler directive somehow.

There must be a simple fix but I'm not sure where to look.

Thanks.

dave
Reply With Quote
  #2 (permalink)  
Old February 20th, 2006, 12:06 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hi Dave,

I ran into this one yesterday. To connect to the database you can use either ADO or DAO technology. From what I understand DAO is the older technology and is being phased out slowly. It appears that your program is using DAO and so to use it, you need to point Access to the right reference file - this is the same type of thing as import or include statements in Java, C++ or other languages.

To do this, go into the VBA editor, go up to Tools, References and then find Microsoft DAO 3.9 or something like it, and check it. After this, your program should work.

Hope that helps,

Mike

Mike
EchoVue.com
Reply With Quote
  #3 (permalink)  
Old February 20th, 2006, 08:09 AM
Registered User
 
Join Date: Feb 2006
Location: Pinehurst, NC, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mike, that did the trick. Thanks so very much!

dave

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C Compiler question imroostercogburn C++ Programming 1 July 5th, 2006 07:43 AM
C# Newbie Question jazzcatone ASP.NET 2.0 Basics 1 May 25th, 2006 10:18 PM
Compiler Error Message: CS0246: The type or namesp frmsasp All Other Wrox Books 0 September 17th, 2005 09:13 AM
Newbie question Beginner VB.NET 2002/2003 Basics 2 November 9th, 2003 07:58 AM
Newbie question maccer88 Access 1 October 18th, 2003 05:53 PM



All times are GMT -4. The time now is 01:09 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.