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

Creating or copying a new Access database 1

Status
Not open for further replies.

ErikZ

Programmer
Feb 14, 2001
266
US
Love this site! :)

Anyway, this is the situation. The database sits on the network, two of the tables it uses (Linked to) are sitting on a floppy disk on the users machine. I made a small database file on the floppy disk. The way this is supposed to work is that the user reads the label on the floppy, and inserts the correct disk for his/her needs.

Now, what I want to do is have access set up a new floppy with the blank tables in it. I thought this would be easy! I have a prototype .mdb file with empty tables that the user manually copies over, but there should be an automatic way to do this. My VBA skills are newbie, and I've been unable to coax a macro to do what I want in any capacity.

sigh,
ErikZ
 
Visual Basic has a filecopy command, is this what you are looking for?

FileCopy SourceFile, DestinationFile
Mike Rohde
rohdem@marshallengines.com
 
Here is an example from the MS Access Help file using the FileCopy command. You could try something like this to copy your prototype database...

Dim SourceFile, DestinationFile

SourceFile = "SRCFILE" ' Define source file name.
DestinationFile = "DESTFILE" ' Define target file name.

FileCopy SourceFile, DestinationFile ' Copy source to target.

Gary
gwinn7
 
(Smacks head)

I keep forgetting this VBA stands for 'Visual Basic'..er, something.

I should of looked in my VB bible. Thanks Gwinn! I cut and pasted your example and only changed two words, it worked perfectly. Now begins the tweaking.

Later
ErikZ

(Where's the "Smacking head emoticon?")
 
That's Great! Good to know its solved!

BTW: VBA = Visual Basic for Applications

Gary
gwinn7
 
Well, it's solved, but I took a different route. I attached this bit to a "New Disk" button.

Private Sub cmdNewDisk_Click()
Dim newdb As Database
Set newdb = CreateDatabase("a:\school.mdb", dbLangGeneral, dbVersion30)
DoCmd.TransferDatabase acExport, "Microsoft Access", "a:\school.mdb", acTable, "DiskStudent", "Students", True
DoCmd.TransferDatabase acExport, "Microsoft Access", "a:\school.mdb", acTable, "DiskSchool", "School", True
End Sub

DiskStudent and Diskschool are blank tables that get copied into the new database. I'm surprised at how long this took me to solve. Guess it was a bad programming day. :)

Later
ErikZ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top