Solved

Creating Tables in VB

Posted on 1998-07-28
3
169 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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code 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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

809 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