Results 1 to 3 of 3

Thread: HELP with MSFlexGrid!!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Posts
    118

    Post

    Hi
    I am trying to use a MSFlexGrid to display data from a MSAccess database.
    Here is my code. I cant get the grid to show the results.I am very NEW to VB
    and any help would be appreciated.
    Thanks

    Private Sub Command1_Click()

    Dim strSQL As String
    strSQL = "SELECT * FROM Customer " & _
    "WHERE (HomePhone = """ & varHomePhone & """);"
    Me.Data2.RecordSource = strSQL
    Me.Data2.Refresh

    Dim strSQL1 As String
    Dim strKey1 As String
    strKey = Text1.Text
    strSQL = "SELECT * FROM Orders " & _
    "WHERE (CustomerID = """ & strKey1 & """);"
    Me.Data1.RecordSource = strSQL1
    Me.Data2.Refresh
    Me.MSFlexGrid1.Refresh
    End Sub

  2. #2
    Member
    Join Date
    Jan 1999
    Location
    Longmont,CO
    Posts
    53

    Post

    I can't really follow the code that you've posted. Here's how I've used the MSHFlexGrid:
    1. Use ADO to open a recordset
    2. Set the recordset property of the MSHFlexGrid to the ADO recordset.

    Dim acon as ADODB.Connection
    Dim arec as ADODB.Recordset

    'set SQL query
    sSQL = string for SQL query

    'instantiate connection & recordset objects
    Set acon = New ADODB.Connection
    Set arec = New ADODB.Recordset

    'define connect string
    sConnectString = connect string to data source

    'make a connection
    acon.Open (sConnectString)

    'get the recordset
    arec.Open sSQL, acon, adoCursor, adoLocking

    'set MSHFlexGrid recordset property
    Set MSHFlexGrid.Recordset = arec

  3. #3
    Member
    Join Date
    Apr 1999
    Location
    Kirkland, WA, USA
    Posts
    40

    Post

    Sorry if this seems silly but have you set the flex's DataMode to bound and the Datasource property to the datacontrol?

    Then refreshing the datacontrol should refil the grid if there are records in the set.

    -S

    ------------------
    http://www.smithvoice.com/vbfun.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width