Solved

Creating Tables in VB

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

813 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

17 Experts available now in Live!

Get 1:1 Help Now