Results 1 to 4 of 4

Thread: Automatically going to a record in flexgrid

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 1999
    Location
    Dillsburg
    Posts
    8

    Post

    I want a flexgrid to go to a certain record when a name is entered into a text box and a button is pushed. The idea is to allow users to be able to get close with "smi" and be able to look at the grid and see "smith" and so on. Thanks for your help and any sample code is appreciated.

    Datacontrol = data1
    textbox = txttargetname
    button = cmdsearch

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Here's an example that searches as you type, it assumes the entries in the grid for the Search Field are Sorted, to change the Search Field, set SEARCH_FIELD to the column Number..

    Code:
    Private Const SEARCH_FIELD = 1
    
    Private Sub txtTargetName_Change()
        Dim I As Integer
        With MSFlexGrid1
            .FocusRect = flexFocusNone
            .SelectionMode = flexSelectionFree
            For I = 1 To .Rows - 1
                If Left(LCase(.TextMatrix(I, SEARCH_FIELD)), Len(txtTargetName)) = LCase(txtTargetName) Then
                    .Row = I
                    .Col = SEARCH_FIELD
                    Exit For
                End If
            Next
        End With
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 1999
    Location
    Dillsburg
    Posts
    8

    Post

    I may not have been clear with my desired results. When typing letters into a text box, I want the flexgrid to follow along with the recordeset in the grid being highlighted as each additional letter is added to the text box.

    The code asbove didnt't seem to work. Any and all help is appreciated

  4. #4
    New Member
    Join Date
    Sep 1999
    Location
    Tamborine, Queensland, Australia
    Posts
    6

    Post

    try this code to display records in a flexgrid as you type in a text box

    Private Sub txt_BySName_Change()
    Dim vs_Part As String
    Dim vi_len As Integer
    vi_len = Len(txt_BySName.Text)
    vs_Part = txt_BySName.Text
    dat_Search.RecordSource = "SELECT [Memb_Code] as Code, [C_Name] as Given, [S_Name] as Surname, [Tel_H] as [Home Telephone] FROM Members WHERE left([S_Name]," & vi_len & ") = '" & vs_Part & "' ORDER BY [S_Name]"
    dat_Search.Refresh
    End Sub

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