how can i create an database dynamically i.e. my code creating database while running taking an user input??

i have seen code like below working

Dim db As Database
Dim ReS As Recordset
Set db = OpenDatabase(App.Path + "\Data\" + Userinput + "\Memo.dat")
Set ReS = db.OpenRecordset("Memo")
ReS.AddNew
ReS("Title") = txtTitle.Text
ReS("Details") = txtDescription.Text


but if i do the same, i get an error - "invalid path"

Re: VB6 database Help Required 80 80

Well first off you need to make sure the directory exists by using the dir function and if it does not exist then you need to use the mkdir statement. HOWEVER, if you are on vista or win7 and in the program files directory, you will not be able to use app.path. Instead, use environ("appdata") & "\ProgramName\Data\nameofmdb.mdb.

Good Luck

Re: VB6 database Help Required 80 80

if the file in same folder

(App.Path & "\db1.mdb")
Re: VB6 database Help Required 80 80

Well first off you need to make sure the directory exists by using the dir function and if it does not exist then you need to use the mkdir statement. HOWEVER, if you are on vista or win7 and in the program files directory, you will not be able to use app.path. Instead, use environ("appdata") & "\ProgramName\Data\nameofmdb.mdb.

Good Luck[/QUO

i am on XP...even after i have made the directory...i am not able to create the desired file....do i need to enable any library files or something??

Re: VB6 database Help Required 80 80

Don't think so but look at Project>References. You should have these four at the top and in this order...

Visual Basic For Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
OLE Automation

Okay, so you are wanting to create an access database and not just open one (as what your code is saying...)

Okay, see post #12 in this thread for an example... http://www.codeguru.com/forum/showthread.php?t=476345

or since you are using DAO start a new project and add the 2.5/3.51 compatability library and then type in...

Dim DB As DAO.Database
Set DB = DBEngine.CreateDatabase

and with the cursor somewhere in or at the end of createdatabase press F1 to bring up help.

Good Luck

commented: Thanks...this helped +0
Re: VB6 database Help Required 80 80

weel theres a function to let the user select a directory, used it to where you save you database to be created. you can also use that to open the database. I think the control is Dialog, opendialog and savedialog box, thats it.

why do you want to create the db during runtime?

Re: VB6 database Help Required 80 80

why not make function that will open another program which will create a database?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.