Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent! Due tomorrow! Connection string

Status
Not open for further replies.

rtvillan

Technical User
Joined
Jan 3, 2002
Messages
9
Location
US
I have a command button that creates a new Access database with the following :
Dim newdata
Dim tb As TableDef
Dim fld As Field
Dim indx As Index
Dim DBNaam$
Dim dbNew As Database

'get name of the new database
newdata = InputBox("What's the name of the database?")
If newdata = "" Then Unload Form1

Screen.MousePointer = vbHourglass
'make database
DBNaam$ = newdata & ".mdb"
Set dbNew = CreateDatabase(DBNaam$, dbLangGeneral, dbVersion30)
'make a table
Set tb = dbNew.CreateTableDef("Table1")
'make a date-field
Set fld = tb.CreateField("Service Date", dbDate)
tb.Fields.Append fld
'make a meno-field
Set fld = tb.CreateField("Cost", dbCurrency)
tb.Fields.Append fld
'make a Yes/No field
Set fld = tb.CreateField("Odometer", dbBoolean)
tb.Fields.Append fld
'make a text field with a length of 8 characters
Set fld = tb.CreateField("Fuel Qty", dbBoolean)
tb.Fields.Append fld

Set fld = tb.CreateField("Service Type", dbText)
tb.Fields.Append fld
dbNew.TableDefs.Append tb

End Sub

How do I get the new database to load automatically thus changing the connection string as well in ADO?

Thanks for anyones help!
 
Can't help with Connection String but I think
If newdata = "" Then Unload Form1
should be changed to

If newdata = "" Then
Unload Form1
exit sub
End if
because as it is execution continues after the Unload.

Compare Code (Text)
Generate Sort in VB or VBScript
 
HI check my FAQ it might be of help to u.
thread181-27567 Murali Bala
 
I'm extremely sorry for pointing to wrong thread
check the below

Create Acess Database, Tables and Fields through VB
faq222-1422 Murali Bala
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top