Hi there experts,

I would like to know that is there any way to filter data in vb6 (data grid, flex grid or etc) as we do in excel spreadsheet? If no, can anyone suggest how to filter records in data grid pls? I'm nw to this.
Please help anyone. Thanks in advance.
Shena

what you mean by like excel here? you want to have filter like excel filter? or just filtering the records in grid?

what about implement the filter at DB level through SQL by generating and executing queries dynamically at run time.

Filter records by using a proper sql statement. It would read something like the code below. You do however need to give us much more information.

Rs.Open "SELECT * FROM MyTable WHERE MyField = '" & Text1.Text & "' ORDER BY MyField DESC", con, adOpenStatic, adLockOptimistic

Hi,

Yes, in excel we're able to filter by column. I just want to know can that same filtering type be done in any grid control in vb?

No, not in any grid directly as is as in Excel sheet.

As far as I can remember, the Microsoft Datagrid control can, with a bit of coding!, can filter by selected column.

Hi guys,
Thanks a lot for the information shared with. From here i understood that there is no way to filter any form of grid in vb6 as we do in excel, correct me if I'm wrong. So, it has to be done through sql queries by placing textboxes in the form.
Thank you all once again.
Shena

No, it can be done by sql and then populating the data. You keep on mentioning excel, is your app in excel or vb6, using a datagrid?

Yes, it has to be done through SQL queries by placing some extra controls like a pair of combobox and textboxes on the form.

commented: Agreed. +7

Hi AndreRet, mine is a vb application that has a datagrid control.
Now, i understand that it can be done by sql which needs an extra control which is combobox.

Correct.:) Do you know how to go about it?

If not open a new post, I'll meet you there.

Hi i have a datgrid bound using a dataenvironment and i need to filter it to display only records with specific text

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.