How to link Microsoft Access to Visual Basic 6.0 ?

As we all know, for creating a software you need a good database which will keep all your data and information in a secured place. Microsoft Access can be used as a database for a software created with the help of Visual Basic 6.0.

Here is a simple illustration of how to connect Microsoft Access with Visual Basic 6.0

1) First open the Visual Basic 6.0. Choose a "Standard EXE" Project.


2) Then on the top, go to "Add-Ins" and select "Visual Data Manager". A 
    separate window named "Visdata" will be opened. From there click on "File"
    and select New -- > Microsoft Access --> Version 7.0 MDB


3) Then give a name (say "db1") to your database save it on the Desktop.
    After saving, a database window will appear where there is a tab named 
    properties. Right click on properties and select "New Table".Give a table
    name (say "tb1") and click on "Add Field".


Always remember to check the "Required" field in each field that you create.
At last, click on "Build the table ". 
You will see a table by the name "tb1" will appear just below the "Properties"

4) Now for convenience, I have shown only three fields namely Name,Roll and
    Marks of a student. Double click on "tb1", click on "Add", enter the field
    data and click on "Update". Add as many data you may like. After that
    close the window.

5) Now on the form, add 3 labels and 3 text boxes. Change the caption   
    names of the labels to Name, Roll and Marks respectively. At the bottom,
    add a Data Scroller. 


6) Now click on the Data Scroller. On the properties window on the right hand side, change the Database name. Select the database that you saved on your desktop. Then find the "RecordSource" where you find your tablename "tb1".



7) Then select each one of your text boxes and on the properties window, click categorized. Then find DataField and DataSource. Under DataSource, select Data1 and under DataField select the corresponding field name with that of your Label Name.


8) After you are done,run the form and use the data scroller to scroll through the data which is stored in the access database.

You can also directly open the access file on your desktop to view the list of data stored in your database.

Leave a comment if you face any difficulty.

Top