?
Solved

create a blank mdb file??

Posted on 2003-02-27
8
Medium Priority
?
844 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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!

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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
Course of the Month8 days, 6 hours left to enroll

765 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