Results 1 to 7 of 7

Thread: GRID problem

  1. #1
    Guest
    Hi All,

    I am stuck with trying to search a dbgrid as I type text in a textbox. I'd like the relevant record to be highlighted as I type the search string in the text box.

    If someone could help, please, I'm really stuck with this.


  2. #2
    Addicted Member pardede's Avatar
    Join Date
    Jan 2000
    Posts
    232
    Code:
    'just a shot
    private sub textbox1_change()
    
      'assume rsGridSource is the recordset of the grid
      'and grdMyGrid as the grid
      rsGridSource.Find = "column_name like " & textbox1 & "*"
    
      grdMyGrid.Refresh 'or .Rebind
    
    end sub
    [Edited by pardede on 05-21-2000 at 01:55 AM]

    [Edited by pardede on 05-21-2000 at 01:56 AM]

  3. #3
    Guest
    Thanks for that. However, the grid I have is a datagrid which is being fed by and ADO data control. I don't have too much experience with this so I'm not sure how to go about applying the code you've written. I can't use it the way it is as I'm not sure how to point it to the relevant recordset.

    I am using an SQL statement within the ADO data control as the recordsource.

    If you have any suggestions I would greatly appreciate it.

  4. #4
    Guest
    I've actually figured out how to apply your code, however it complains about the asterisk between the double quotes.

    Also, it only works for the first character typed in. Any ideas on how it can keep on looking as you keep on typing?

    Thanks.

  5. #5
    Guest
    You'll probably think I'm a fruit loop. This code actually does what I want it to do, without that asterisk though. I don't know how I didn't notice it before.

    Thanks very much. It works great!!

  6. #6
    Addicted Member pardede's Avatar
    Join Date
    Jan 2000
    Posts
    232
    Hi,
    There's a little flaw in my code, there should be single quotes sorrounding the text being sought in the sql so it should have read:

    Code:
    rsGridSource.Find = "column_name like '" & textbox1 & "*'"

  7. #7
    Guest
    Thanks again. I notice it only works with text but not numbers. Works great though. 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