| View previous topic :: View next topic |
| Author |
Message |
leynie Newbie
Joined: 28 Aug 2005 Posts: 11
|
Posted: Oct 5th, 2005 11:40 AM Post subject: Continuosly populating a list from database matching input |
|
|
Hi,
I am trying to work on an application that once there is an input text1.text and enter key is pressed, it will display the matching record of the text1.text from the database. Once the input text1.text is changed, the next matching record will be displayed below the first record and so on... i think what i am trying to say is to populate a list of records (ID, name, price) matching the user input text1.text (ID)....
I have tried using MS HFG linked to database for displaying the matching records. Well, it works but it only displays one record at a time. For example, if text1.text = ID1 then it would display the matching record for ID1 but when for the next input text1.text = ID2, the HFG would refresh and clear the previous record and display the current matching record.... (does this sound too confusing..? )
The following is the code snippet for displaying the matching record:
Dim SQL As String
SQL = "select ID, NAME, PRICE from product where ID like '" & Text1.Text & "%'"
adcproduct.RecordSource = SQL
adcproduct.CommandType = adCmdText
adcproduct.Refresh
Set hfgproduct.DataSource = adcproduct
Any idea on how i can go about populating the HFG continuosly with matching records without clearing the previous records as the user key in the IDs? Or HFG is not the appropriate control for this purpose? Any other control that i can use?
Thanks! Any guide and help is very much appreciated!
cheers,
leynie |
|
| Back to top |
|
dougthomas Moderator
Joined: 27 Jul 2005 Posts: 271 Location: Essex, UK
|
Posted: Oct 8th, 2005 01:46 AM Post subject: |
|
|
Hi Leynie,
A solution which might not be the most elegant is to use the additem method for the Grid instead of setting the data source.
Something like
| Code: |
hfgproduct.AddItem adcproduct![ID] & vbtab & adcproduct![NAME] & vbtab & adcproduct![PRICE]
|
This will add a new row. The vbtab's set the column.
Hope this helps
Regards
Doug _________________ If you can see the light at the end of the tunnel, it probably means there's a Train coming. |
|
| Back to top |
|
leynie Newbie
Joined: 28 Aug 2005 Posts: 11
|
Posted: Oct 9th, 2005 05:44 AM Post subject: |
|
|
Hi,
Thanks for your reply
I have added the command and there was error.. I am bounding the ADODC control (adcProduct) to the database actually with the code as shown before... So i guess the line of code you have shown to add a new row is to use ADO without the ADODC right (without bounding control)?
Thanks in advance!
cheers,
leynie |
|
| Back to top |
|
dougthomas Moderator
Joined: 27 Jul 2005 Posts: 271 Location: Essex, UK
|
Posted: Oct 9th, 2005 05:54 AM Post subject: |
|
|
Hi again,
Yes that was the idea. Just leave the grid unbound to any data source and populate it directly from the recordset via .additem
What sort of error are you seeing ?
Regards
Doug _________________ If you can see the light at the end of the tunnel, it probably means there's a Train coming. |
|
| Back to top |
|
leynie Newbie
Joined: 28 Aug 2005 Posts: 11
|
Posted: Oct 10th, 2005 04:20 AM Post subject: |
|
|
Hi,
Hmm.. the error was due to the addition of the command .additem in the previous program which is used for ADODC where control is bounded....
After some reading up and help, i have managed to change the program to continuosly matching the Text1.Text with the records in the database (using the ADO without ADODC) and displaying it under the previous records (using .additem) in hierarchical flexgrid without clearing the the whole list as the old code used to do....
Hmm.. now I am wondering if there is a way to always show the latest few included records in the flexgrid without the user scrolling down the scrollbar to view the latest records added? (because once the hierarchical flexgrid is being populated, a scrollbar will appear but it is always showing the first few included records instead of the latest few.. )
Thanks again for your guide and help!
cheers, |
|
| Back to top |
|
dougthomas Moderator
Joined: 27 Jul 2005 Posts: 271 Location: Essex, UK
|
Posted: Oct 10th, 2005 05:02 AM Post subject: |
|
|
Hi,
There is a .TopRow property in the Grid which "Sets or Returns the uppermost row displayed..."
It *may* be worth playing wiht that, if you know that Row 45 was the last one added you could try setting .TopRow to something like 40.
Regards
Doug _________________ If you can see the light at the end of the tunnel, it probably means there's a Train coming. |
|
| Back to top |
|
|