Results 1 to 6 of 6

Thread: [RESOLVED] Flexgrid search/Add to new flexgrid

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    40

    Resolved [RESOLVED] Flexgrid search/Add to new flexgrid

    Last part of my problem...I have this search function that searches through a flexgrid I have on my interface, and it works great...now what I need to do is bring each record that is found into a separate flexgrid with the same properties as the parent flexgrid, with just the records that were found...
    any suggestions?


    This is my search function:


    VB Code:
    1. Sub Search()
    2.     Dim target_name As String, sResult As String
    3.     Dim r As Integer, c As Integer, sResultArray() As String, sra As Integer
    4.    
    5.     target_name = UCase$(InputBox("Letter", "Letter"))
    6.     If Len(target_name) = 0 Then Exit Sub
    7.    
    8.     With grd
    9.         .Redraw = False
    10.         .FillStyle = flexFillRepeat
    11.         .Col = 1: .Row = 1
    12.         .ColSel = .Cols - 1
    13.         .RowSel = .Rows - 1
    14.         .CellBackColor = vbWhite
    15.        
    16.         For r = 0 To .Rows - 1
    17.             For c = 1 To .Cols - 1
    18.                 If .TextMatrix(r, c) Like target_name & "*" Then Exit For
    19.             Next c
    20.             If c < .Cols Then
    21.                 For c = 1 To .Cols - 1
    22.                     sResult = sResult & vbTab & .TextMatrix(r, c)
    23.                 Next c
    24.  
    25.                 sResult = vbNullString
    26.             End If
    27.         Next r
    28.         .Col = 0: .Row = 0
    29.         .Redraw = True
    30.     End With
    31.    
    32.     MsgBox "Finished!"
    33.    
    34.    
    35.    
    36. End Sub

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Flexgrid search/Add to new flexgrid

    is the problem that you can't transfer the records? cos i told you how to do that before:
    VB Code:
    1. MSFlexGrid1.AddItem sResult
    or is it that you need to create a duplicate of the FlexGrid (stylistically)?

  3. #3

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    40

    Re: Flexgrid search/Add to new flexgrid

    That only added the first column, and not any of the supplementary records...I'm thinking some sort of a split is necessary and a cycle through an array for each row...?

  4. #4

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    40

    Re: Flexgrid search/Add to new flexgrid

    I need to create a whole new flexgrid from the original flexgrid...with only the selected records being brought over...

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Flexgrid search/Add to new flexgrid

    that only showed the first column, because you probably only had one column in the target grid. you'll need to set the right number of cols and rows and copy all the headers over.

    it might be easier for you just to 'hide' the rows that didn't match:
    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim target_name As String, sResult As String
    3.     Dim r As Integer, c As Integer
    4.    
    5.     target_name = InputBox("Name", "Name")
    6.     If Len(target_name) = 0 Then Exit Sub
    7.    
    8.     With MSFlexGrid1
    9.         .Redraw = False
    10.         .FillStyle = flexFillRepeat
    11.         .Col = 1: .Row = 1
    12.         .ColSel = .Cols - 1
    13.         .RowSel = .Rows - 1
    14.         .CellBackColor = vbWhite
    15.         .Col = 0: .Row = 0
    16.        
    17.         .RowHeight(-1) = .RowHeight(0)
    18.         For r = 1 To .Rows - 1
    19.             For c = 1 To .Cols - 1
    20.                 If .TextMatrix(r, c) Like target_name & "*" Then Exit For
    21.             Next c
    22.             If c = .Cols Then .RowHeight(r) = 0
    23.         Next r
    24.         .Redraw = True
    25.     End With
    26. End Sub

  6. #6

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    40

    Re: Flexgrid search/Add to new flexgrid

    Works great, thanks!!!

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