PDA

Click to See Complete Forum and Search --> : GRID problem


May 18th, 2000, 07:36 AM
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.

pardede
May 20th, 2000, 06:54 AM
'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]

May 20th, 2000, 02:02 PM
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.

May 20th, 2000, 02:09 PM
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.

May 20th, 2000, 02:12 PM
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!! :)

pardede
May 21st, 2000, 01:15 PM
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:

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

May 21st, 2000, 01:29 PM
Thanks again. I notice it only works with text but not numbers. Works great though. Thanks.