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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSFlexGrid, Help!!!

Status
Not open for further replies.

octane

Programmer
Aug 19, 2001
12
MX
I need to fill a MSFlexGrid

Some one give an idea

I have this code but, it doesn't not work
Dim cad As String
cad = "SELECT clave_des,comp_des FROM destinatario WHERE comp_des LIKE " & "'*" & txt_Buscar.Text & "*'"

Data1.RecordSource = cad
Data1.Refresh
grid.Cols = 3
grid.TextMatrix(0, 1) = "clave_des"
grid.TextMatrix(0, 2) = "comp_des"
For i = 0 To Data1.Recordset.RecordCount - 1
grid.TextMatrix(i + 1, 0) = i + 1
cad = grid.TextMatrix(i + 1, 1)
cad = "clave_des = " & comillas & cad & comillas
Data1.Recordset.FindFirst cad
Next
grid.ColWidth(0) = 700
grid.ColWidth(1) = 1500
grid.ColWidth(2) = 2060
 
Have you tried this:

Set grid.DataSource = Data1

If that works you shouldn't have to manually populate the grid.

Hope that helps!

-Mike Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
 
Try this:

---this code is for the appearance:
Me.MSFlexGrid.ColWidth(0) = 200
Me.MSFlexGrid.ColWidth(1) = 2000
Me.MSFlexGrid.ColWidth(2) = 2000
Me.MSFlexGrid.ColWidth(3) = 2500

Me.MSFlexGrid.Row = 0
Me.MSFlexGrid.Col = 1
Me.MSFlexGrid.Text = "X"
Me.MSFlexGrid.Col = 2
Me.MSFlexGrid.Text = "Y"
Me.MSFlexGrid.Col = 3
Me.MSFlexGrid.Text = "Z"

---This code is for filling it up:
Dim sSQL As String
Dim sData As String
Dim fRs As Recordset

sSQL = "SELECT tbl.X, tbl.Y, "
sSQL = sSQL & "tbl.Z "
sSQL = sSQL & "FROM tbl"
sSQL = sSQL & " ORDER BY tblCompound.X"

Set fRs = database.OpenRecordset(sSQL, dbOpenSnapshot)

If fRs.RecordCount = 0 Then
Me.MSFlexGrid.Rows = 1
Else
fRs.MoveFirst
Me.MSFlexGrid.Rows = 1
Do Until fRs.EOF = True
sData = "" & Chr$(9)
sData = sData & fRs("X") & Chr$(9)
sData = sData & fRs("Y") & Chr$(9)
sData = sData & fRs("Z") & Chr$(9)

Me.MSFlexGrid.AddItem sData
fRs.MoveNext
Loop
End If

fRs.Close
Set fRs = Nothing

Have fun...
 


For i = 0 To Data1.Recordset.RecordCount - 1

'This looks ok, displaying a counter
grid.TextMatrix(i + 1, 0) = i + 1

'column 1 of grid has no value so cad is always ""
cad = grid.TextMatrix(i + 1, 1)

cad = "clave_des = " & comillas & cad & comillas

Data1.Recordset.FindFirst cad

Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top