Using code to create a new database on a 3.5 floppy

rcaban

New member
Local time
Today, 10:14
Joined
Oct 4, 2002
Messages
6
What exact code or type of code should I use to automatically create a new blank database on a 3 1/2" floppy disk? If it is possible, could I use a macro to do it as well?
 
Yes, it's possible. Just create the db in your hd first, for the speed sake, then copy the db to a floppy disk when finished.

I don't know if Macros could handle this or not. Check the CreateDatabase Method in Help.
 
Creating databases with event procedures

Well, what I'm exactly trying to do is have an event triggered that would create a database onto a floppy disk, export a table from my current database to the one on the disk, and then append information to the exported table in the new database on the disk. I'm having trouble coming up with an event procedure that will allow me to do that. I tried looking in help and online to see if there was anything I could use but no luck. :cool:
 
Here's how to create a blank db and copy a table to it.

Sub CreateNewDB()
Dim wsp As Workspace
Dim dbs As Database
Dim strDBFile As String
strDBFile = "A:\NewDB.mdb"
Set wsp = DBEngine.Workspaces(0)
Set dbs = wsp.CreateDatabase(strDBFile, dbLangGeneral)
DoCmd.CopyObject strDBFile, , acTable, "Table1"
dbs.Close
Set dbs = Nothing
Set wsp = Nothing
End Sub
 
Instead of having to create a database each time why not just copy a blank from the HD?
 
Compile errors

For some reason there is a compile error for these two statements:

Dim wsp As Workspace
Dim dbs As Database
 
Make sure you have set DAO in the References. Go to Tools menu>References..> Look for Microsoft DAO 3.X Object Library and select it.

Now try the code again and it should work out for you now.
 

Users who are viewing this thread

Back
Top Bottom