Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating a Flex Grid from a recordset

Status
Not open for further replies.

rundmc

Programmer
Jan 16, 2003
15
US
I'm tring to populate a Flex Grid from a search of a database table. I am unsure of the method that the Flexgrid would use to add the values of the recordset to the Flexgrid itself. Has any one any ideas??
 
Without binding it to a data control? Then use AddItem.
 
If it you are using MSHFlexGrid, then you can use

MSHFlexGrid1.DataSource = rst

Where MSHFlexGrid1 will be the Flex Grid Name, And rst is Recordset.
 
To populate a flexgrid with a recordset I step though the recordset and grid one row at a time, growing the grid to equal to records in the recordset:

Step 1: get your recordset (mine is mrsOrders)


Step 2: set up the first row of the grid with titles, color, alignment, etc


With FlexGridAllocate ' Note:col&row #s start at ZERO (0), not ONE (1)

.Rows = 2
.Cols = 6
.FixedCols = 0

' format fixed rows, numbered 0,1,2,3
.Row = 0 ' column names
.Col = 0: .Text = "Order": .ColWidth(0) = 900
.Col = 1: .Text = "Stop": .ColWidth(1) = 500
.Col = 2: .Text = "Item": .ColWidth(2) = 1300
.Col = 3: .Text = "Line": .ColWidth(3) = 550
.Col = 4: .Text = "Cases": .ColWidth(4) = 550
.Col = 5: .Text = "Pallets": .ColWidth(5) = 600
end with


Step 3: fill the grid with your records:


With FlexGridAllocate
.Row = 0
Do While mrsOrders.EOF = False
If .Row = (.Rows - 1) Then .Rows = .Rows + 1
.Row = .Row + 1:
.Col = 0
.Text = mrsOrders("ord_nbr")
.Col = 1
.Text = mrsOrders("stop_seq")
.Col = 2
.Text = mrsOrders("item_nbr")
.Col = 3
.Text = mrsOrders("line_nbr")
.Col = 4
.Text = mrsOrders("item_case")
mrsorders.movenext
loop
End With


Hope that helps

Jax

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top