|
-
Aug 29th, 2009, 07:22 PM
#1
Thread Starter
Lively Member
[RESOLVED] creating new mdb file?
Hi all,
my objective is to open a csv file and save it to new mdb file at "c:\my_file" directory.
how to create new mdb file in vb6 code? the file name of the mdb will be base on csv file name.
many thanks!
-
Aug 29th, 2009, 08:21 PM
#2
Re: creating new mdb file?
A new database for each new file? Sounds very unreasonable.
Instead, if csv files will always have the same layout then you can design a table and load it with new data.
For each new load you will need to assign so unique id or at least date it was loaded.
Whether you design one table or multple (they will have to relate somehow) is up to you.
-
Aug 29th, 2009, 08:30 PM
#3
Re: creating new mdb file?
Why did you start this thread when you marked your other similar thread as resolved?
-
Aug 29th, 2009, 08:54 PM
#4
Thread Starter
Lively Member
Re: creating new mdb file?
 Originally Posted by MartinLiss
Hi Martinliss,
I think my previous thread it solved only the parsing of the txt file then add to existing mdb. my problem now is how will i create new mdb file? i want to make it automated in creating this mdb file.
-
Aug 30th, 2009, 04:50 AM
#5
Re: creating new mdb file?
Here is a very basic way to create an MDB file... First please set a reference to Microsoft DAO 3.6 Object Library
Remember this is a just a basic example of how to create an MDB. Please amend it as per your requirements...
vb Code:
'~~> Set reference to Microsoft DAO 3.6 Object Library Private Sub Command1_Click() '~~> Replace this with your path and filename CreateDB "c:\my_file\Mydatabase.mdb" End Sub Sub CreateDB(mdbPath As String) Dim tdefMDB As TableDef, txtFieldone As Field, txtFieldtwo As Field Dim dateFieldone As Field, memoFieldone As Field, dbDatabase As Database Dim sNewDBPathAndName As String sNewDBPathAndName = mdbPath Set dbDatabase = CreateDatabase(sNewDBPathAndName, dbLangGeneral, dbEncrypt) '~~> Create new TableDef (I am creating a table Table1) Set tdefMDB = dbDatabase.CreateTableDef("Table1") '~~> Add fields to MDB '~~> for eample I am creating two text fields, 1 date field and '~~> 1 memo field. Amend as applicable Set txtFieldone = tdefMDB.CreateField("txtField1", dbText, 20) Set txtFieldtwo = tdefMDB.CreateField("txtField2", dbText, 20) Set dateFieldone = tdefMDB.CreateField("dateField1", dbDate) Set memoFieldone = tdefMDB.CreateField("memoField1", dbMemo) '~~> Append the field objects to the TableDef tdefMDB.Fields.Append txtFieldone tdefMDB.Fields.Append txtFieldtwo tdefMDB.Fields.Append dateFieldone tdefMDB.Fields.Append memoFieldone '~~> Save TableDef definition by appending it to TableDefs collection. dbDatabase.TableDefs.Append tdefMDB '~~> Inform user. MsgBox "New .MDB Created - '" & sNewDBPathAndName & "'", vbInformation End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Aug 30th, 2009, 01:38 PM
#6
Frenzied Member
Re: creating new mdb file?
Useful Code 
- do you have a list of available options to hand? such as settng primary key? and indexed etc
-
Aug 30th, 2009, 04:59 PM
#7
Re: creating new mdb file?
@Wayne:
vb Code:
Dim ind As DAO.Index '~~> rest of the code as mentioned above .... Set ind = tdefMDB.CreateIndex("PrimaryKey")
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Aug 30th, 2009, 07:25 PM
#8
Re: creating new mdb file?
As DAO is seriously outdated it is better (and actually recommended) option to use ADOX library.
There are plenty of samples throughout the this forum and also DB Forum.
-
Aug 31st, 2009, 03:54 AM
#9
Re: creating new mdb file?
I absolutely agree with Rhino that DAO is outdated and I myself use the ADOX but this is the only scenario where I use DAO probably because I remember this code like the back of my hand and it makes me create the MDB in no time.... Guess I am too lazy now a days...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Aug 31st, 2009, 05:54 AM
#10
-
Aug 31st, 2009, 06:33 AM
#11
Re: creating new mdb file?
Yeah I use it very often... like I mentioned, I am too lazy
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Sep 1st, 2009, 08:22 AM
#12
Thread Starter
Lively Member
Re: creating new mdb file?
Koolsid,
Thank you!
-
Sep 1st, 2009, 10:34 AM
#13
Re: creating new mdb file?
 Originally Posted by Chowking
Koolsid,
Thank you! 
Glad to be of help
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|