PC Review


Reply
Thread Tools Rate Thread

combobox uncorrect result

 
 
Belu33fr
Guest
Posts: n/a
 
      20th Feb 2009
Hi,
I have a adp (access 2003 sp3) with sql server 2000. On a simple form with a
simple recordsource query, a combobox (cbt) with a standard sql query in
rowsource. All event proc are running well (it is a linked control). The
query result is a large set of records. I imagined a solution where with the
"change" event, I computed a "where" clause for my query as "where personName
LIKE 'xxx%'" with xxx is the start of word striked by the user.

Private Sub cbt_Change()
cbt.RowSource = "SELECT TOP 8 N_person AS GUID, Name + ' ' + Surname AS
Label FROM Person WHERE Name + ' ' + Surname LIKE '" & Mid(cbt.Text, 1,
cbt.SelStart) & "%' ORDER BY Name + ' ' + Surname"
End Sub

This works correctly (combo is correctly populated, suggest is ok, edit is
ok) except when you use "enter" or "tab" keys before the end of the word
(cbt.sellength>0). The combobox stores a value that's not expected.

I said to myself, maybe I made something wrong and I tried it with a
classical mdb. It's work fine.

Somebody has an idea.

Thanks
 
Reply With Quote
 
 
 
 
Sylvain Lafontaine
Guest
Posts: n/a
 
      24th Feb 2009
Yup, that seems to be another ADP's bug. I would suggest that you create
instead an unbound combobox and change the value of the record in its
AfterUpdate event.

A second possibility would be to set the rows source as a list instead of a
query string but I don't know if this will work OK in this case.

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain aei ca (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)


"Belu33fr" <(E-Mail Removed)> wrote in message
news:853EA0B1-94BE-4A32-A670-(E-Mail Removed)...
> Hi,
> I have a adp (access 2003 sp3) with sql server 2000. On a simple form with
> a
> simple recordsource query, a combobox (cbt) with a standard sql query in
> rowsource. All event proc are running well (it is a linked control). The
> query result is a large set of records. I imagined a solution where with
> the
> "change" event, I computed a "where" clause for my query as "where
> personName
> LIKE 'xxx%'" with xxx is the start of word striked by the user.
>
> Private Sub cbt_Change()
> cbt.RowSource = "SELECT TOP 8 N_person AS GUID, Name + ' ' + Surname AS
> Label FROM Person WHERE Name + ' ' + Surname LIKE '" & Mid(cbt.Text, 1,
> cbt.SelStart) & "%' ORDER BY Name + ' ' + Surname"
> End Sub
>
> This works correctly (combo is correctly populated, suggest is ok, edit is
> ok) except when you use "enter" or "tab" keys before the end of the word
> (cbt.sellength>0). The combobox stores a value that's not expected.
>
> I said to myself, maybe I made something wrong and I tried it with a
> classical mdb. It's work fine.
>
> Somebody has an idea.
>
> Thanks



 
Reply With Quote
 
Belu33fr
Guest
Posts: n/a
 
      24th Feb 2009
Hi,
Thanks for your answer. I followed your first way before your message. It
was a little bit complicated (around you need many things). I did not
imaginated your second way. But, this last evening, I found something
interresting. The time where Access makes change, select, and so and is
between keypress and change event. So, because the change of the rowsource is
too late in the change event, I think that it is the reason of this uncorrect
result, but I'm not sure.
In all case, I made a little test in the keypress event and all is fine. I
include this solution into my final code and it is good.
The code of my test:
Private Sub Cbt_KeyPress(KeyAscii As Integer)
Dim A As String
A = Chr(KeyAscii)
If AscB(A) < 32 And AscB(A) = 127 Then A=""
cbt.RowSource = "SELECT TOP 8 N_person AS GUID, Name + ' ' + Surname AS
Label FROM Person WHERE Name + ' ' + Surname LIKE '" & Mid(cbt.Text, 1,
cbt.SelStart) & A & "%' ORDER BY Name + ' ' + Surname"
End Sub

Thanks for your help and idea.
Luc


"Sylvain Lafontaine" wrote:

> Yup, that seems to be another ADP's bug. I would suggest that you create
> instead an unbound combobox and change the value of the record in its
> AfterUpdate event.
>
> A second possibility would be to set the rows source as a list instead of a
> query string but I don't know if this will work OK in this case.
>
> --
> Sylvain Lafontaine, ing.
> MVP - Windows Live Platform
> Email: sylvain aei ca (fill the blanks, no spam please)
> Independent consultant and remote programming for Access and SQL-Server
> (French)
>
>
> "Belu33fr" <(E-Mail Removed)> wrote in message
> news:853EA0B1-94BE-4A32-A670-(E-Mail Removed)...
> > Hi,
> > I have a adp (access 2003 sp3) with sql server 2000. On a simple form with
> > a
> > simple recordsource query, a combobox (cbt) with a standard sql query in
> > rowsource. All event proc are running well (it is a linked control). The
> > query result is a large set of records. I imagined a solution where with
> > the
> > "change" event, I computed a "where" clause for my query as "where
> > personName
> > LIKE 'xxx%'" with xxx is the start of word striked by the user.
> >
> > Private Sub cbt_Change()
> > cbt.RowSource = "SELECT TOP 8 N_person AS GUID, Name + ' ' + Surname AS
> > Label FROM Person WHERE Name + ' ' + Surname LIKE '" & Mid(cbt.Text, 1,
> > cbt.SelStart) & "%' ORDER BY Name + ' ' + Surname"
> > End Sub
> >
> > This works correctly (combo is correctly populated, suggest is ok, edit is
> > ok) except when you use "enter" or "tab" keys before the end of the word
> > (cbt.sellength>0). The combobox stores a value that's not expected.
> >
> > I said to myself, maybe I made something wrong and I tried it with a
> > classical mdb. It's work fine.
> >
> > Somebody has an idea.
> >
> > Thanks

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ComboBox appear as a result of value chosen in another ComboBox =?Utf-8?B?QW50b25pb1Jpbw==?= Microsoft Access Forms 5 19th Jun 2007 04:27 AM
Form bounds uncorrect =?Utf-8?B?Um9iS2lubmV5MQ==?= Microsoft C# .NET 0 16th Oct 2006 03:40 PM
Using multiple combobox's to filter down a result. =?Utf-8?B?c2t1bG1hdA==?= Microsoft Access Forms 1 19th Jun 2005 12:50 PM
ComboBox Row Source = Result of DB Query? Zachary Turner Microsoft Dot NET Framework Forms 1 26th Sep 2004 03:56 PM
Combobox not displaying expected result. Mitch Microsoft Access Forms 3 10th Sep 2004 05:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:51 AM.