Link to home
Start Free TrialLog in
Avatar of Rowan Scott
Rowan ScottFlag for Australia

asked on

Create a new mdb (Access Database) from the code in Visual Basic (visual studio express)

Hi.

I  am writing a vb application that needs to be able to work from several access databases.  The data bases will be essentially the same just different accounts so to speak.

This means I will need to be able to create a new blank database from  the code if the user chooses to add another account.   How would I do this?  I'm a bit new to visual studio so take it slow.

It doesn't have to be an access database. that's just what i'm used to working with.

Best regards
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Why don't you have a template (empty database) and just make a copy when required?
Avatar of Rowan Scott

ASKER

That's a good idea.  Do you know how to make a copy with vb code or how to include the template with the installer.
In the installer you can include the database and for copy you just need to do IO.File.Copy(sourceFile,destFile)
Do I make the mdb database manually first using Microsoft Access.  Sorry I'm very new to visual studio.  I have done lots of vba in excel though so I'm hoping I will pick it up before too long.
>> Do I make the mdb database manually first using Microsoft Access
Yes, it's the easy way! :)
OK.

I know how to use an mdb from excel's vba but i'm sure there would be a better way in visual studio.

Can you give me any clues.
I'm not getting this.  I've made the mdb database and embedded it.  

I cant even work out how to read and write to an embedded text file yet.  How do you refer to text files (i will get onto the database later) if they are embedded because you don't know their full address.

Sorry to be so slow!

ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yippee, thanks jpaulino

Now I can just make copies of the database whenever the user wants to add an account.

I still need to keep a record of what accounts have been added which I thought to do in an "Accounts.txt" file in the resources but your help has solved my original question.

I've used your function so I'm proud to have some resident Portuguese comments in my application now!

 
Thanks very much.
Glad I could help and I think the Portuguese comments will look nice on your application :)
Cheers!