strange keypress - combo box action

Davros

Registered User.
Local time
Today, 21:40
Joined
Sep 9, 2005
Messages
131
Hi
I have a search form which runs a query [QBF] where the results are displayed in another form. no problem
However i am using a keypress down event to run the search. I need to search by the two fields 'grave number' and 'section'. 'grave number' is a text field and 'section' is a drop down combo box. If I type '4' in the 'grave number' field and TYPE 'B section' in the 'section' field ( or only 'B se' so that the phrase B section automatically appears) the search only returns all records that have the number 4 in them. However if I pick the phrase 'B section' from the drop down list of the combo box then the seach will return what it should - all graves called 4 in B section.
why is it if I type 'B section' in the combo box the search will not work yet if I pick the phrase 'B section' from the drop down list it works?
I very mystified so any help appreciated.
thanks
 
Is it possible that your combo box is not set to limit to list, and by typing part of the phrase it is actually searching on the wrong item.

Just a thought, because you're right, it shouldn't matter if you pick or type the item.
 
good reply
but
no thats not the answer
thanks anyway!
 
one other problem I have noticed is that if I type another search criteria in my search form such as 'surname' then again the keypress event will not bring up the correct results. I am also running the QBF [Query by Form] event from another command using VB which prints the results. This is running perfectly and the report gets its results from the same query. The only difference I can see is that the QBF works if ran by a command button yet fails to work properly if ran by a keypress event.
 
found the answer but i'm not sure if I should feel stupid or not.
basically upon entering text in the combo box i need to move into another field before i run the QBF. To this end i have changed the keypress event to setfocus on another field first then run the query.
simple - but i have never come across this before.
 
The reason for this is that the AfterUpdate of the combo box has not occurred unless you force it somehow. When you click on an item in the combo box, it's AfterUpdate event fires and you get the value changed. If you type it in, it doesn't count that as updated until you exit the field.

The text box control is similar as until it's AfterUpdate event you won't get the correct value if you have typed in it. That's why for times when you need to type and capture the typing in a text box you want Me.YourTextBoxName.Text instead of the default Me.YourTextBoxName which has .Value as it's default.
 
thanks for making that clear Boblarson
 

Users who are viewing this thread

Back
Top Bottom