Requery on Combo Box

D

Dave Hawks

I am using a Subform to allow users to reserve times by selecting their name
from a combo box. To speed up navigation the combobox is based on a query and
when selected the standard parameter input box appears and requests the user
to type in the first initial of their surname.When theydo so and press OK
they are presented with a subset of the full list of names from which they
can select and hence enter their own name.
This works for the first record but if the user moves to the next record
without first closing and reopening the main form, the popup does not appear
but the user is presented with exactly the same subset based on their inital
selection in the parameterbox.
To overcome this I attached the following code to the gotfocus event of the
combobox:-
Me.ActiveControl.Requery
This ensures that everytime the user moves to a new record they are
presented with a fresh parameter box requesting their initial.
The parameter box has two options after entering data "OK" or "Cancel". On
first opening the form the user can select either, but after entering data in
one record and moving to a new record , if they select "Cancel" Access
crashes completely with the message "microsoft access for windows has
encountered a problem and needs to close"
Can anyone suggest why and a potential fix?
 
K

Klatuu

I have no idea what the error is, but might I suggest you abandon the
approach? If you just set the Auto Expand property of the combo box to Yes,
it will not only take care of that for you, it will be easier for the user.
It does the "type ahead" thing, so that it keeps narrowing the list as you
type. I believe what you are trying to do would slow the search rather than
speed it up.
 
T

TonyT

A possible cause is that the gotfocus event is happening again after the
'cancel' button is pressed, nad everything is left in limbo as regards the
recordsource to requery.
Anyway, I'm with Klatuu on the way to approach dealing with it and I'm sure
you won't have a problem unless you have tens of thousands of names in the
combobox, then you might want to think about a sub-sort first, but even then
another prior combobox would probably be your best bet, with just Initials in.

TonyT..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top