Combo box Drop down

  • Thread starter Thread starter Annelie
  • Start date Start date
A

Annelie

I have a client where I use access 2003 in access 2002 format and when I use
the following code it works great.

Private Sub EmployeeSelect_Change()
EmployeeSelect.Dropdown
End Sub

On another client is keep getting error messages and I think it must be
because some library is not loaded. What could it be?
Annelie
 
I lost this post.
Run-Time Error 2185. You can't reference a property or methos for a control
unless the control has the focus.
This is in Access 2002, access 2000 format.
Annelie
 
That error message suggests that the code is being "called" when the combo
box EmployeeSelect does not have the focus. When you say it's working on one
client's machine but not on the other's, then two possibilities come to
mind:

(1) The one client is doing something differently from the other client that
causes this code to run when the combo box doesn't have the focus.

(2) The database (or the form) on the client's machine that is erroring may
be corrupted. Try replacing the database file with one that is working.
 
The two databases are in the basic structure the same, but are still very
different. I wrote both. This particular form, however, it the same in both
programs. I don't seem to have a problem in Access 2003, but with Access
2002 I am constantly running into different little problems like this.
Perhaps the libraries are a little different. I need to put my access 2002
on their server, so I can convert the data to 2002 and then perhaps some of
the problems will disappear. I only have one user over there and he has
2002.

I was able to resolve the below problem by putting it into the On Enter
event. It works well and no error message.
Thanks for your help.
I would like to understand this focus thing. When you scroll through the
combo box, it does not have focus until you actually select one item of the
list. Strangely enough, the message does not appear until after an employee
is selected. The curser at that time sits on the employee name field of the
main form. Conditional formatting shows that the combo box has focus when
the list drops down, then the focus shifts to the EmployeeName field on the
main form. Perhaps something is corrupted.
Annelie
 
The dropdown option for a combo box can only be shown when the combo box has
the focus. Thus, I don't understand your statement that you can scroll
through the combo box list but that the combo box doesn't have the focus
until an item is selected. In order to scroll through the list, the combo
box must have the focus.

Your statement about how, after an item is selected, the cursor ends up in
another control, suggests to me that you have code running on the
AfterUpdate event of the combo box that is moving the focus from the combo
box to the other control. I think you have code running here than what
you've posted so far.

Your solution to use the OnEnter event for the showing the dropdown list is
ok; alternatively, you can use the OnGotFocus event (which probably would be
my choice) to do the same thing. The OnChange event occurrs whenever a
character is typed into the control or an item is selected from the dropdown
list (or from a listbox's list). As such, it's used for special things when
you want to examine each character or when something else needs to occur as
soon as the control's contents are "dirtied".

If you open the module behind the form, there likely is more code that is
running on various events. If you can post that, perhaps we can figure out
exactly what is happening in this "wayward" form.
 
Back
Top