Database Object
The first thing you must do in your application is to open a database where your tables are stored. You need to declare a variable to hold your database in order to do this. This is done with:Dim dbMyDB As Database
This gives you a variable/object that can hold a reference to your database. To open a simple Access database named "MyDatabase.mdb", do this:Set dbMyDB = OpenDatabase("MyDatabase.mdb")
You should really specify the complete path to the db, but if your current directory is the directory where the database is situated, this will work.
So, now you have opened a database. This won't give you any data. What you need to do is open a table in the database. You're not limited to open a single table; sometimes you have two or more tables that are related to each other and linked together w ith foreign keys, and there are ways to handle this to. But in this "Visual Basic - Database Primer" I will only show you how to open a single table
No comments:
Post a Comment