PDA

Click to See Complete Forum and Search --> : tbales, sorting by value


spandex44
Nov 15th, 1999, 03:47 PM
hi! I wanted to know if there's any VB control which you can use as a table. I want to sort the value of different variables from biggerst to smallest. Does anyone know an easy way to do this? Thanks in advance,
Alexander McAndrew

Serge
Nov 15th, 1999, 06:15 PM
If you're talking about to show the data from the table in your VB application then you can use an SQL statement to specify the order.

Select * From MyTable Order By Column1 Desc


Regards,

------------------

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)



[This message has been edited by Serge (edited 11-16-1999).]

spandex44
Nov 15th, 1999, 08:50 PM
thanks, but how can I create a table and add things to it during run-time? Should I use an excel chart? Or is their a VB control I can use? Thanks in advance,
Alexander McAndrew

Serge
Nov 15th, 1999, 09:42 PM
You can use any controls that suites your needs. For example, lets say you have a table called Customer. So the table Customer structure will look something like this:

Fields
CustID - Autonumber
CustFName - Text
CustLName - Text
Address - Text
City - Text
State - State
Zip - Text
Phone - Text

So, the best way is to create a control array of TextBoxes. So, lets say we have a contols array named txtInfo (7 textboxes)
And now we want to save the info you typed in the textboxes (the CustID will be created automatically). Also, in this sample I assume that the database is an Access database.


Dim db As Database
Dim rs As Recordset
Dim i As Integer

Set db = Workspaces(0).OpenDatabase("D:\Microsoft Visual Studio\VB98\Nwind.mdb")
Set rs = db.OpenRecordset("Customer", dbOpenTable)

rs.AddNew
For i = 0 To txtInfo.UBound
rs(i + 1) = txtInfo(i)
Next
rs.Update




Regards,

------------------

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)



[This message has been edited by Serge (edited 11-16-1999).]