Solved

Creating Tables in VB

Posted on 1998-07-28
3
181 Views
Last Modified: 2010-05-03
How do you create a Table in Visual Basic?  We have a database at work that was created in VB.  Whenever we need to create a table, it looks fine until we go back in and view it.  At this point, the rows and columns have shifted and sometimes you can't even tell it was a table.

Please help.  Thank you.
0
Comment
Question by:Pebbles
[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
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Dalin earned 100 total points
ID: 1467011
Pebbles,
Try this. Let me know if you have questions
Regards
Dalin

Dim mydb as Database
Dim MyTD as TableDef
Dim MyField1 as Field

Set MyDB = DBEngine.WorkSpaces(0).Opendatabase("YourDBwithPath")
Set myTD = myDB.CreateTableDef("YourTableName")
Set MyField1=MyTD.CreateField("YourFieldName", dbInteger) 'assume integer

'if you want to create more filed, go here
MyTD.Fields.Append MyField1
'...
MyDB.Tabledefs.Append MyTD
MyDb.Close
Now you created the table, just fill it with data


0
 

Author Comment

by:Pebbles
ID: 1467012
After I give this response to our programmer at work, I may be able to rate this higher.  As a user inputting information, I wouldn't know how to do this.

What we do is go into our VB database.  There is also a Word 6.0 document behind the screen.  We put our information into the Word document and then copy and paste it into the Database.  It is then that we see that VB did not accept our tables in the format we created them.  

So, I guess, more to the point:  we never know when a table is needed.  Is there something we, as users, can do OR must we notify our IS area every time we want to create a table so that they can code it as your directed above?

I'm new to this and really do appreciate your help.
0
 

Author Comment

by:Pebbles
ID: 1467013
After I give this response to our programmer at work, I may be able to rate this higher.  As a user inputting information, I wouldn't know how to do this.

What we do is go into our VB database.  There is also a Word 6.0 document behind the screen.  We put our information into the Word document and then copy and paste it into the Database.  It is then that we see that VB did not accept our tables in the format we created them.  

So, I guess, more to the point:  we never know when a table is needed.  Is there something we, as users, can do OR must we notify our IS area every time we want to create a table so that they can code it as your directed above?

I'm new to this and really do appreciate your help.
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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

717 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