Create Access database with VB

Mat

Well-known Member
Joined
Sep 17, 2003
Messages
509
Hi, I'm fairly new in using access...

I have a text file that I want to convert into a mdb file with VB, I know how to do it directly in Access, but I want to do it from a vb application...

The first line is the headers, and the column separator is the ";"

Is there a simple way of doing it ?

thanks
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi Mat

This code will add a new MS Access database called Mat in the root directory:

Code:
Sub CreateDatabase()

    Dim cat As New ADOX.Catalog
    cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Mat.mdb"

End Sub

You need to add a reference to the "Microsoft ADO Ext.2.1 For DDL and Security" library.

To create a new table in your new database and add data from a text file requires a lot of work with code to add the table, the columns (with data typing), Primary Keys, Foreign keys, Indexes and to Append all these objects to the new database. It's really not worth the effort if you already have Access on your machine.

If you really, really want to do so then read up on the ADOX library. All the methods are available there.

Try that

anvil19
:eek:
 
Upvote 0

Forum statistics

Threads
1,221,773
Messages
6,161,855
Members
451,724
Latest member
sledparty

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top