-
September 5th, 2012, 11:00 AM
#1
How to search for a certain record in a MSHFlexGrid?
I have a MSHFlexGrid that gets all records via a recordset from a database.
I want to add a search function so that it would search for the data entered by the user on to the search textbox. But it should search for the data only in a certain column in the MSHFlexGrid.
Can anyone please give me the code for this?
And I'm very sorry if the question is not clear. If it is not, please inform me. I will do my best to make it more understandable.
-
September 5th, 2012, 12:07 PM
#2
Re: How to search for a certain record in a MSHFlexGrid?
You shouldn't be loading ALL RECORDS of anything into the grid. The user needs to see between 1 and 25 records (one screen).
You would have to QUERY each record as a separate QUERY, or else FILTER based on the records.
You CAN load the data into a recordset and procress it from there, though. Just don't BIND it to the grid.
I have an article that uses a grid. You can find it here
-
September 9th, 2012, 08:39 AM
#3
Re: How to search for a certain record in a MSHFlexGrid?
Its true you shouldn't load 300,000 records into a grid as this will be a badly designed application - however a few hundred, even a few thousand rows does not upset your program speed so lond as you have a good sized memory - 2-4GB minimum
To answer your question about searching through a grid, you could do the following
Lets say your Search Column is Customer Code from a Table Called Customers
You could simply say "Select * from Customers Where Customer_Code = '" & Text1.text & "'"
Then execute the select statement to get the record you wanted
This would negate the need for filling a grid and would happily work on a table with 1000, 10000, or 100000 records without problem
Lets now assume you have run a query something like
"Select Record_Type, Customer_Code, Customer_Name from Customers "
- and have filled the grid below
Grid.FormatString = " |<Record Type |<Customer Code |<Customer Name "
To find a Customer Code (value in Text1.text ) in Column Number 2 (1st column = Column 0) you would simply say
Dim R as long
Dim C as long
For R = 1 to Grid.Rows -1
Grid.Row = R
Grid.Col = 2
If Grid.text = Text1.text then
MSGBOX " Record Found"
Goto .......................
EndIf
Next R
MSGBOX " Record NOT Found"
Goto ..........................
If you are dealing with a large amount of data in a grid then, to speed things up, do as follows
Dim R as long
Dim C as long
Grid.Visible = False
Grid.Redraw = False
For R = 1 to Grid.Rows -1
Grid.Row = R
Grid.Col = 2
If Grid.text = Text1.text then
Grid.Visible = True
Grid.Redraw = True MSGBOX " Record Found"
Goto .......................
EndIf
Next R
Grid.Visible = True
Grid.Redraw = TrueMSGBOX " Record NOT Found"
Goto ..........................
PS -WHERE HAS THE CODE BLOCKING ICON DISAPPEARED TO ?
(Is this another W7 ? - Cant seem to find anything, anymore)
Last edited by George1111; September 9th, 2012 at 08:46 AM.
-
September 9th, 2012, 12:13 PM
#4
Re: How to search for a certain record in a MSHFlexGrid?
Its true you shouldn't load 300,000 records into a grid as this will be a badly designed application - however a few hundred, even a few thousand rows does not upset your program speed so lond as you have a good sized memory - 2-4GB minimum
Guess you've never had a SQL SERVER w/5000 users each accessing the same 1,000 records.
Why read 100 records unless you plan to process them ALL?
Also, code tags are in with quote tags (in ADVANCED EDITOR). You know you can also just TYPE the quote tags yourself?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|