Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting

Post new topic   Reply to topic
Continuosly populating a list from database matching input
View previous topic :: View next topic  
Author Message
leynie
Newbie


Joined: 28 Aug 2005
Posts: 11

PostPosted: Oct 5th, 2005 11:40 AM    Post subject: Continuosly populating a list from database matching input Reply with quote

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..?Eek )

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
View user's profile Send private message
dougthomas
Moderator


Joined: 27 Jul 2005
Posts: 271
Location: Essex, UK

PostPosted: Oct 8th, 2005 01:46 AM    Post subject: Reply with quote

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
View user's profile Send private message
leynie
Newbie


Joined: 28 Aug 2005
Posts: 11

PostPosted: Oct 9th, 2005 05:44 AM    Post subject: Reply with quote

Hi,

Thanks for your reply Smile

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
View user's profile Send private message
dougthomas
Moderator


Joined: 27 Jul 2005
Posts: 271
Location: Essex, UK

PostPosted: Oct 9th, 2005 05:54 AM    Post subject: Reply with quote

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
View user's profile Send private message
leynie
Newbie


Joined: 28 Aug 2005
Posts: 11

PostPosted: Oct 10th, 2005 04:20 AM    Post subject: Reply with quote

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.... Smile

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.... Smile

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! Smile


cheers,
Back to top
View user's profile Send private message
dougthomas
Moderator


Joined: 27 Jul 2005
Posts: 271
Location: Essex, UK

PostPosted: Oct 10th, 2005 05:02 AM    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic