|
-
Jan 25th, 2004, 10:24 PM
#1
Thread Starter
Hyperactive Member
access vba
I am brand new to vba for access and I tried running some examples from a book I read, but the objects I am referencing are not being recognized (like dim db as database). Do I have to reference or import anything first? The code that doesn't work is as follows:
VB Code:
Option Compare Database
Sub exaCreateQuery()
Dim db As database
Dim rs As Recordset
Set db = CurrentDb
End Sub
produces the error: user defined type not defined
-
Jan 26th, 2004, 03:44 AM
#2
Addicted Member
You may not have enabled the VBA references.
Go to VB Editor and look at the list under Tolls/References. Check any Object Library that seems appropriate.
You may need to re-run the setup disk/custom setup to add Visual Basic items. They are not always installed by default.
Regards
BrianB
-------------------------------
-
Jan 26th, 2004, 05:22 AM
#3
The main way to access databases is by using ADO (ActiveX Data Objects). It may be worth your while searching the net for a quick tutorial on getting started with this.
As above, you can add the ADO libraries / code which you can call on, by going to the tools menu > references opption & checking the box next to the "Microsoft Activex Data Objects x.x object library" entry.
I believe the code you are using above from this book is teaching you how to code using the DAO object libraries. This can also be accessed by adding a reference (as above) to the "Microsoft Data Access Object x.0 Object Library", & adding this in will make the above code work & should present intellisense in your code.
I would recommend looking up a tutorial on ADO first as DAO is an older and less efficient technology used back in the days of office 97 etc.
-
Jan 26th, 2004, 11:30 AM
#4
Thread Starter
Hyperactive Member
RESOLVED
Thank you, that is what I suspected.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|