Home All Groups Group Topic Archive Search About
Author
11 Oct 2005 8:40 AM
jack
Hi to populate a combobox with one of the field from the database we
have to run a while loop which will add items in combobox like this

    While Not rst.EOF = True
        combo1.AddItem rst.Fields("name")
        rst.MoveNext
    Wend


can this be done in other way to increase the speed.

Author
11 Oct 2005 9:17 AM
Larry Lard
jack wrote:
> Hi to populate a combobox with one of the field from the database we
> have to run a while loop which will add items in combobox like this
>
>     While Not rst.EOF = True
>         combo1.AddItem rst.Fields("name")
>         rst.MoveNext
>     Wend
>
>
> can this be done in other way to increase the speed.

How long does it take at the moment? Is this the slowest part of your
application?

--
Larry Lard
Replies to group please
Author
11 Oct 2005 9:45 AM
Jan Hyde
"jack" <gautams.m***@gmail.com>'s wild thoughts were
released on 11 Oct 2005 01:40:31 -0700 bearing the following
fruit:

>Hi to populate a combobox with one of the field from the database we
>have to run a while loop which will add items in combobox like this
>
>    While Not rst.EOF = True
>        combo1.AddItem rst.Fields("name")
>        rst.MoveNext
>    Wend
>
>
>can this be done in other way to increase the speed.

If this is causing a noticable delay then you must be adding
a significant number of items to the combo box, surely far
more than is practical.



Jan Hyde (VB MVP)

--
I saw a sign today that read "LOTS FOR SALE" but when I stopped I saw
absolutely nothing. (Jim E. Snibbler)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
Author
11 Oct 2005 1:11 PM
Norm Cook
I have found the following loop to be somewhat faster
Dim i As Long
For i = 1 to rst.RecordCount
>         combo1.AddItem rst.Fields("name")
>         rst.MoveNext
Next

Probably because it eliminates the EOF checking

Show quoteHide quote
"jack" <gautams.m***@gmail.com> wrote in message
news:1129020031.297067.33760@z14g2000cwz.googlegroups.com...
> Hi to populate a combobox with one of the field from the database we
> have to run a while loop which will add items in combobox like this
>
>     While Not rst.EOF = True
>         combo1.AddItem rst.Fields("name")
>         rst.MoveNext
>     Wend
>
>
> can this be done in other way to increase the speed.
>
Author
11 Oct 2005 1:38 PM
Jeff Johnson [MVP: VB]
"Norm Cook" <normcookNOSPAM@cableone.net> wrote in message
news:11knefica2f2la9@corp.supernews.com...

> I have found the following loop to be somewhat faster
> Dim i As Long
> For i = 1 to rst.RecordCount
>>         combo1.AddItem rst.Fields("name")
>>         rst.MoveNext
> Next
>
> Probably because it eliminates the EOF checking

But of course this assumes that you have opened your recordset in such a way
that the RecordCount property has been filled with the true number of
records.
Author
11 Oct 2005 1:14 PM
_john_
Try to create custom function like this

on textbox1_change
    query = "select top 1 from table1 where field1 like ' " &
me.textbox1.text & " %' "
    execute query
    lenght = len(textbox1.text)
    textbox1 = result from query
    textbox1.selstart = lenght
    texbox1.sellenght = 0


syntax is not correct but I think u see what I menthe
Hope it helps


john
Author
11 Oct 2005 1:40 PM
Jan Hyde
"_john_" <j***@microsoft.com>'s wild thoughts were released
on Tue, 11 Oct 2005 15:14:34 +0200 bearing the following
fruit:

Show quoteHide quote
>Try to create custom function like this
>
>on textbox1_change
>    query = "select top 1 from table1 where field1 like ' " &
>me.textbox1.text & " %' "
>    execute query
>    lenght = len(textbox1.text)
>    textbox1 = result from query
>    textbox1.selstart = lenght
>    texbox1.sellenght = 0
>
>
>syntax is not correct but I think u see what I menthe
>Hope it helps

I'm not sure how that would help the OP, but firing off an
SQL on a textbox change event is certainly a good way to
slow things down further ;-)



Jan Hyde (VB MVP)

--
I saw this bloke chatting up a cheetah, I thought "he's trying to
pull a fast one". 

[Abolish the TV Licence - http://www.tvlicensing.biz/]
Author
12 Oct 2005 8:37 AM
_john_
I use it and works just fine. Can you explain, please.

regards,
John

Show quoteHide quote
"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
news:i4gnk1110hgu014b7m4hekbe2mal9pg7dm@4ax.com...
> "_john_" <j***@microsoft.com>'s wild thoughts were released
> on Tue, 11 Oct 2005 15:14:34 +0200 bearing the following
> fruit:
>
>>Try to create custom function like this
>>
>>on textbox1_change
>>    query = "select top 1 from table1 where field1 like ' " &
>>me.textbox1.text & " %' "
>>    execute query
>>    lenght = len(textbox1.text)
>>    textbox1 = result from query
>>    textbox1.selstart = lenght
>>    texbox1.sellenght = 0
>>
>>
>>syntax is not correct but I think u see what I menthe
>>Hope it helps
>
> I'm not sure how that would help the OP, but firing off an
> SQL on a textbox change event is certainly a good way to
> slow things down further ;-)
>
>
>
> Jan Hyde (VB MVP)
>
> --
> I saw this bloke chatting up a cheetah, I thought "he's trying to
> pull a fast one".
>
> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>
Author
12 Oct 2005 10:32 AM
Jan Hyde
"_john_" <j***@microsoft.com>'s wild thoughts were released
on Wed, 12 Oct 2005 10:37:40 +0200 bearing the following
fruit:

>I use it and works just fine. Can you explain, please.

Sure, your psudo code doesn't seem to have anything to do
with populating a combo box, the OP's question was how to
speed up populationg the combo box.

As far as firing SQLs off on a change event goes, it may
well work fine for you for now, but the slowest part of any
database application is the database access. You might not
notice it now, but throw multiple users, remote databases,
busy networks, large tables etc into the mix and suddenly
you can find an app becomes unusable.

Generally firing off several sqls that returns only 1 record
will take more time overall than firing 1 SQL to return many
records and it would also increase database activity which
could impact other users.

J





Show quoteHide quote
>regards,
>John
>
>"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
>news:i4gnk1110hgu014b7m4hekbe2mal9pg7dm@4ax.com...
>> "_john_" <j***@microsoft.com>'s wild thoughts were released
>> on Tue, 11 Oct 2005 15:14:34 +0200 bearing the following
>> fruit:
>>
>>>Try to create custom function like this
>>>
>>>on textbox1_change
>>>    query = "select top 1 from table1 where field1 like ' " &
>>>me.textbox1.text & " %' "
>>>    execute query
>>>    lenght = len(textbox1.text)
>>>    textbox1 = result from query
>>>    textbox1.selstart = lenght
>>>    texbox1.sellenght = 0
>>>
>>>
>>>syntax is not correct but I think u see what I menthe
>>>Hope it helps
>>
>> I'm not sure how that would help the OP, but firing off an
>> SQL on a textbox change event is certainly a good way to
>> slow things down further ;-)
>>
>>
>>
>> Jan Hyde (VB MVP)
>>
>> --
>> I saw this bloke chatting up a cheetah, I thought "he's trying to
>> pull a fast one".
>>
>> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>>
>


Jan Hyde (VB MVP)

--
Who knocks on your door selling Halloween cookies?
Ghoul Scouts

(Ken Pinkham)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
Author
12 Oct 2005 10:59 AM
_john_
Ok, now I understand now. But what do you suggest? I have table with 50.000
records, field for example "ProductCode". If I load this in combo, loading
takes long time and make a lot of trafic on network. Instead I make textbox,
and do like I write before. Is it better to load all records in recordset
after first character is putted in textbox and then I filter this recordest?

regards,
John

Show quoteHide quote
"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
news:jjopk1pbqjup7ok9bk67d81cuke7kofsep@4ax.com...
> "_john_" <j***@microsoft.com>'s wild thoughts were released
> on Wed, 12 Oct 2005 10:37:40 +0200 bearing the following
> fruit:
>
>>I use it and works just fine. Can you explain, please.
>
> Sure, your psudo code doesn't seem to have anything to do
> with populating a combo box, the OP's question was how to
> speed up populationg the combo box.
>
> As far as firing SQLs off on a change event goes, it may
> well work fine for you for now, but the slowest part of any
> database application is the database access. You might not
> notice it now, but throw multiple users, remote databases,
> busy networks, large tables etc into the mix and suddenly
> you can find an app becomes unusable.
>
> Generally firing off several sqls that returns only 1 record
> will take more time overall than firing 1 SQL to return many
> records and it would also increase database activity which
> could impact other users.
>
> J
>
>
>
>
>
>>regards,
>>John
>>
>>"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
>>news:i4gnk1110hgu014b7m4hekbe2mal9pg7dm@4ax.com...
>>> "_john_" <j***@microsoft.com>'s wild thoughts were released
>>> on Tue, 11 Oct 2005 15:14:34 +0200 bearing the following
>>> fruit:
>>>
>>>>Try to create custom function like this
>>>>
>>>>on textbox1_change
>>>>    query = "select top 1 from table1 where field1 like ' " &
>>>>me.textbox1.text & " %' "
>>>>    execute query
>>>>    lenght = len(textbox1.text)
>>>>    textbox1 = result from query
>>>>    textbox1.selstart = lenght
>>>>    texbox1.sellenght = 0
>>>>
>>>>
>>>>syntax is not correct but I think u see what I menthe
>>>>Hope it helps
>>>
>>> I'm not sure how that would help the OP, but firing off an
>>> SQL on a textbox change event is certainly a good way to
>>> slow things down further ;-)
>>>
>>>
>>>
>>> Jan Hyde (VB MVP)
>>>
>>> --
>>> I saw this bloke chatting up a cheetah, I thought "he's trying to
>>> pull a fast one".
>>>
>>> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>>>
>>
>
>
> Jan Hyde (VB MVP)
>
> --
> Who knocks on your door selling Halloween cookies?
> Ghoul Scouts
>
> (Ken Pinkham)
>
> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>
Author
12 Oct 2005 11:57 AM
Jan Hyde
"_john_" <j***@microsoft.com>'s wild thoughts were released
on Wed, 12 Oct 2005 12:59:19 +0200 bearing the following
fruit:

>Ok, now I understand now. But what do you suggest?

I'd first query why they would need to be loaded into a
combo at all. If someone were to enter a ProductCode which,
once entered does something then I would trigger that
'something' in a different way, either by the user doing
something, like clicking on a submit button or via some
other event.

Without knowing the specifics of what your doing it's
difficult to make a suggestion.

>I have table with 50.000
>records, field for example "ProductCode". If I load this in combo, loading
>takes long time and make a lot of trafic on network. Instead I make textbox,
>and do like I write before. Is it better to load all records in recordset
>after first character is putted in textbox and then I filter this recordest?

No, I'd say it's better to load in the specific record once
the entire product code has been entered.








Show quoteHide quote
>regards,
>John
>
>"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
>news:jjopk1pbqjup7ok9bk67d81cuke7kofsep@4ax.com...
>> "_john_" <j***@microsoft.com>'s wild thoughts were released
>> on Wed, 12 Oct 2005 10:37:40 +0200 bearing the following
>> fruit:
>>
>>>I use it and works just fine. Can you explain, please.
>>
>> Sure, your psudo code doesn't seem to have anything to do
>> with populating a combo box, the OP's question was how to
>> speed up populationg the combo box.
>>
>> As far as firing SQLs off on a change event goes, it may
>> well work fine for you for now, but the slowest part of any
>> database application is the database access. You might not
>> notice it now, but throw multiple users, remote databases,
>> busy networks, large tables etc into the mix and suddenly
>> you can find an app becomes unusable.
>>
>> Generally firing off several sqls that returns only 1 record
>> will take more time overall than firing 1 SQL to return many
>> records and it would also increase database activity which
>> could impact other users.
>>
>> J
>>
>>
>>
>>
>>
>>>regards,
>>>John
>>>
>>>"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
>>>news:i4gnk1110hgu014b7m4hekbe2mal9pg7dm@4ax.com...
>>>> "_john_" <j***@microsoft.com>'s wild thoughts were released
>>>> on Tue, 11 Oct 2005 15:14:34 +0200 bearing the following
>>>> fruit:
>>>>
>>>>>Try to create custom function like this
>>>>>
>>>>>on textbox1_change
>>>>>    query = "select top 1 from table1 where field1 like ' " &
>>>>>me.textbox1.text & " %' "
>>>>>    execute query
>>>>>    lenght = len(textbox1.text)
>>>>>    textbox1 = result from query
>>>>>    textbox1.selstart = lenght
>>>>>    texbox1.sellenght = 0
>>>>>
>>>>>
>>>>>syntax is not correct but I think u see what I menthe
>>>>>Hope it helps
>>>>
>>>> I'm not sure how that would help the OP, but firing off an
>>>> SQL on a textbox change event is certainly a good way to
>>>> slow things down further ;-)
>>>>
>>>>
>>>>
>>>> Jan Hyde (VB MVP)
>>>>
>>>> --
>>>> I saw this bloke chatting up a cheetah, I thought "he's trying to
>>>> pull a fast one".
>>>>
>>>> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>>>>
>>>
>>
>>
>> Jan Hyde (VB MVP)
>>
>> --
>> Who knocks on your door selling Halloween cookies?
>> Ghoul Scouts
>>
>> (Ken Pinkham)
>>
>> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>>
>


Jan Hyde (VB MVP)

--
Insinuate: Adam and Eve’s least favorite word (Johnny Hart)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
Author
12 Oct 2005 12:34 PM
J French
On Wed, 12 Oct 2005 12:59:19 +0200, "_john_" <j***@microsoft.com>
wrote:

>Ok, now I understand now. But what do you suggest? I have table with 50.000
>records, field for example "ProductCode". If I load this in combo, loading
>takes long time and make a lot of trafic on network. Instead I make textbox,
>and do like I write before. Is it better to load all records in recordset
>after first character is putted in textbox and then I filter this recordest?

Much against the advice of most people here, I have often presented
users with what looks like a list of 20,000  ...  100,000 records

It comforts them

Of course the trick is to just grab a few more records than you need
to display on screen

Basically, present them with a 'virtual listbox' or if you want to get
flashy /fake/ a combo
Author
12 Oct 2005 6:24 PM
Chris Kusmierz
"jack" <gautams.m***@gmail.com> wrote in message
news:1129020031.297067.33760@z14g2000cwz.googlegroups.com...
> Hi to populate a combobox with one of the field from the database we
> have to run a while loop which will add items in combobox like this
>
>     While Not rst.EOF = True
>         combo1.AddItem rst.Fields("name")
>         rst.MoveNext
>     Wend
>
>
> can this be done in other way to increase the speed.

Make the combobox sorted property false?

Chris
Show quoteHide quote
>
Author
13 Oct 2005 8:51 AM
jack
Is Datacombo gonna me in this?