Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database declaration error. 2

Status
Not open for further replies.

Robeen

Programmer
Mar 25, 2003
38
US
I am getting a compile error:
'User defined type not defined'
on the following line in General Declarations:
Dim dbMyDB As Database

I'm trying to connect to an Access DB with VB 6.0
I'm using what looks like pretty standard DB connection code
but I can't get past Dim dbMyDB As Database . . .
I want to be able to get values from the db into local variables, insert, modify, delete records . . .
I've done the ADODC thing and want to get past that.
Any ideas, code samples, suggestions, tutorials . . . ?
 
Is Microsoft DAO 3.x Object Library selected in your project's references?
If you're "moving on" from data bound controls, you might consider using ADO instead of DAO. DAO is older technology and, although its great with Access databases, ADO is more flexible.
 
Either

1. Set reference to to DAO (3.5, 3.6, etc) and declare your dbs as a DAO.database

or

2. Forsake the DBS object alltogether as it's not required using the ADODB object model.

Example:
Code:
Dim rstTo As New ADODB.Recordset
rstTo.Open "tblYourTable", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
With rstTo
   .stuff goes here
End With

Tyrone Lumley
augerinn@gte.net


 
Thanks for both responses! The last time I did VB was in 1997. I don't know anything about ADODB.
Is there a site where I can copy & paste code - or look at a full example?
I'm not able to make use of Tyrone's snippet because I don't understand it.
Thanks again. I guess I need to look in the VB Help under ADODB . . . :)
Robin [pronounced 'Robeen' in Bengal, India].
 

To get started with ADO code you can use the DataForm wizard and ask for ADO code. This will give you some sample stuff to start with

Project|Add Form|VB DataForm Wizard
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top