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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Compact Access db in VB?

Status
Not open for further replies.

NeilDT

Technical User
Apr 11, 2001
13
GB
Does anyone know how to compact an Access database using Visual Basic 6? The database is being manipulated via ADO.
 
I don't know the answer to this, but you might have more luck posting to the Access or VBA forum. Dawn
 
For a start, you can do this with some controls. Later on, you can do this by writing some code instead of using controls.
The following example will show the content of your database in a Grid control and you will be able to manipulate the content of your database from VB.
Steps:
Add 1 Data-control to your form
The “Properties” for this control:
- Connect = “Acces” (if your database has the extension .mdb)
- DatabasName = The location of your database
- RecordsetType = “Dynaset” (Enables you to manipulate your database from VB)
- RecordSource = The name of a table from your database

Now add the following control to your Form:
“Microsoft Data Bound Grid Control 5.0 (DBgrid32.ocx)”
The “Properties” for this control:
- DataSource = The name of your Data-control
Right-click at your DBGrid-control (on the Form) and a dropdown menu appears.
Select “Retrieve Fields”

That’s it.

The following example shows all the records in a table called Table1, where “Month” = 3
Data1.RecordSource = "Select * from Table1 where Month = 3'"
Data1.Refresh
To show all the content of your database again:
Data1.RecordSource = "Select * from Table1"
Data1.Refresh
Read more about using SQL in the help-file in “Microsoft Access”.

If you want to use your database without using Controls, then try this link:

Regards from KBBJ (-:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top