Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 19th, 2006, 11:19 PM
Registered User
 
Join Date: Feb 2006
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
 
Old February 20th, 2006, 12:06 AM
Friend of Wrox
 
Join Date: Oct 2004
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
 
Old February 20th, 2006, 08:09 AM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

dave






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.