Binding DataSource

yuanxinsui
06-29-2000, 07:49 PM
Hi:
I want to bind a recordset create online to Microsoft FlexGrid Control 6.0 dynamiclly through code, not through Data Control, how do I do that?

Ergent!!!
I'll be very appreciated for your help!

Boom007
07-08-2000, 02:32 PM
i have done it and it works like a charm.The data control hassle is [censored].
So here u go i am sendin a .txt with some example of what and how...for more help email me or meet me on icq bet. 9-12 india time.

I am here to help and take some help in return.

Chris25NJ
11-22-2002, 03:15 PM
would have been helpful if you posted this for anyone else.....

Dale S
11-22-2002, 03:38 PM
This my help, Chris

This will work with an Access DB. Replace with your own SQL statement. The FlexGrid Name is msh . I declaired sConn here, only for an example, It should be in a Module as Public , so it can be accessed from anywhere.

In your FormLoad Event call these procedures

FormatGridBefore
FormatGrid
FormatGridAfter


Private Sub FillGrid()
'DECLAIR RECORDSET VARIABLES
Dim rs As ADODB.Recordset, sql As String, sConn As String

sConn = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & App.Path & "\timecard.mdb;Persist Security Info=False"

'SELECT RECORDS IN LAST NAME FIRST NAME ORDER SO FLEX GRID WILL FILL CORRECTLY
sql = "SELECT Address.L_Name, Address.F_Name, Address.E_Address " _
& "FROM Address " _
& "ORDER BY L_Name"
'NEW ADODB RECORDSET
Set rs = New ADODB.Recordset
rs.Open sql, sConn, adOpenKeyset, adLockOptimistic, adCmdText

'SET FLEX GIRD DATA SOURCE TO THE RECORDSET
Set msh.DataSource = rs
msh.Visible = False
msh.Refresh
msh.Visible = True

'CLOSE AND CLEAR RS FROM MEMORY TO RECLAIM RESOURCES
rs.Close
Set rs = Nothing
End Sub

Public Sub FormatGridAfter()
'FORMAT FLEX GRID HEADINGS AND COLUMN WIDTHS
With msh
.FormatString = "Last Name|First Name|Email Address"
.ColWidth(0) = 1520
.ColWidth(1) = 1520
End With
End Sub

Public Sub FormatGridBefore()
'FORMAT FLEX GRID TO 0
msh.FixedCols = 0
End Sub


Hope this helps

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum