Solved

create a new database from textboxes?

Posted on 1998-03-02
4
142 Views
Last Modified: 2011-09-20
how do i create a new database from textboxes
which the user enters input..
like i have a "name:" textbox , "NRIC" textbox
and the user enter the data in these
textboxes and presses the submit button to
create a new database record..
0
Comment
Question by:Netboy
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Dalin
ID: 1458281
The easiest way is to create the database from Microsoft  Access or use the VB data mamanager.
Create database and the table:
On your VB desing enviroment, goto the menu "Add-In/Visual Data manager"
The data manager window will come out. Select the menu "File/New/Microsoft Access/Version7.0" (choose the proper database for youself). Enter the name of your database.
you should get the database interface.
Now right click the mouse and select "New Table"
Enter the name of your table. Then click on "Add Field"
You should be able to enter the information about all field in your table. When done, click on "Build table".

Now you have your table. Select "Utility/Data Form Designer", enter a name for the form, and slect your table as the record source, select all the fields. and click on OK.

You should get the form you want.

0
 

Author Comment

by:Netboy
ID: 1458282
i want to create a table from what the user inputs..
not what i create...
0
 

Author Comment

by:Netboy
ID: 1458283
how do i do this in access 97?
0
 
LVL 7

Accepted Solution

by:
tward earned 20 total points
ID: 1458284
The following will allow you to create a database on the fly within VB (for Access):

Public dbWorkspace As Workspace
Public dbDatabase As Database
Public dbTable1Def As TableDef
Public dbTable2Def As TableDef
Public dbFilename As Field
Public dbPageNumber As Field
Public dbPath As Field
Public dbHeader As Field

' Create the Database '
Set dbWorkspace = DBEngine.Workspaces(0)
Set dbDatabase = dbWorkspace.CreateDatabase("Database.mdb", dbLangGeneral)

' Create the Tables '
Set dbTable1Def = dbDatabase.CreateTableDef("Table1Name")
Set dbTable2Def = dbDatabase.CreateTableDef("Table2Name")

' Create the Fields '  
Set dbFilename = dbTable1Def.CreateField("Filename", dbText, 12)
Set dbPageNumber = dbTable1Def.CreateField("PageNumber", dbText, 8)
Set dbHeader = dbTable1Def.CreateField("Header", dbText, 10)

Set dbPath = dbTable2Def.CreateField("Path", dbText, 255)

' Append the Fields to the Appropriate Tables '  
dbTable1Def.Fields.Append dbFilename
dbTable1Def.Fields.Append dbPageNumber
dbTable1Def.Fields.Append dbHeader
dbTable2Def.Fields.Append dbPath

' Append the Tables to the Database '  
dbDatabase.TableDefs.Append dbTable1Def
dbDatabase.TableDefs.Append dbTable2Def
dbDatabase.Close
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now