Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

create a blank mdb file??

Posted on 2003-02-27
8
Medium Priority
?
869 Views
Last Modified: 2012-05-04
Hi,

I would like to know how can I create a blank mdb file by code?
0
Comment
Question by:ping1234
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 33

Accepted Solution

by:
hongjun earned 200 total points
ID: 8039286
Try this.
Before you do that, do this

Project->References
Make sure "Microsoft DAO 3.x Object Library" is checked.


Option Explicit

Private Sub Form_Load()
    CreateDatabase "c:\db1.mdb"
End Sub


Private Function CreateDatabase(DBFullPath As String) As Boolean
Dim db As Database

On Error GoTo ErrorHandler
Set db = DBEngine.CreateDatabase(DBFullPath, dbLangGeneral)

CreateDatabase = True
ErrorHandler:
If Not db Is Nothing Then db.Close

End Function


hongjun
0
 

Author Comment

by:ping1234
ID: 8039382
Thanks for your help!
0
 
LVL 3

Expert Comment

by:Da_Weasel
ID: 8039400
Unless your adding to an existing program that uses DAO I would use ADO for this.
You can use the ADOX object
You will need to add a reference to the "Microsoft ADO Ext. for DDL and Security"

You can then use the ADOX.Catalog and ADOX.Table objects to make your database.

If you want a complete explaination just let me know and i will post it.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 33

Expert Comment

by:hongjun
ID: 8039407
Thanks for selecting my comment as the answer. But why the grade of "B"? It could have been an A grade since my comment solved your problem directly. Note that a grade A given does not differ from a grade B or C to a questionner. It will not affect your question points value but rather it only affect your grading record. Your grading record will be better if you shows consistent A grading awarding habit.

Please see Tip #11 - Grade quickly and fairly
http://cd-eepages.fateback.com/asking.html

Please explain the reason for the B grade.

hongjun
0
 

Author Comment

by:ping1234
ID: 8039451
I am very sorry that I am fresh in using the Expert Exchange system, so I don't really know the grading system.

Is there any way to change the posed grade?

0
 
LVL 3

Expert Comment

by:Da_Weasel
ID: 8039524
Well it wasn't the best way to solve the problem, so it only seems fitting that the grade was not an A.  That would imply that you not only solved the problem but did so in the best possible way.
It seems like the grade letters fly around a bit to easily, I am constently seeing people get A's for adhoc spagehtti code simply because it works.  Most of the time it doesnt actually solve the problem, it just puts a bandaid on it.  I don't think honqiun's code falls into that category, it was good and solved the problem, but I think that a grade of B is fair.
Why complain about a good grade?
0
 
LVL 5

Expert Comment

by:Netminder
ID: 8039540
Per agreement, grade changed.

Netminder
EE Admin
0
 
LVL 3

Expert Comment

by:Da_Weasel
ID: 8039547
sorry, i didnt quite understand the grading system....honqion's code is definately an A

honquin: my appologie...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question