Error 2185

C

Chad Cameron

Hi All,

I am using Access 2000.

We are using a form to enter employee timecards. The way it is set up now,
I have to enter the employee number for every entry. What I want to do is
add a textbox and have the drop down list of employees check it the textbox
has a number in it. If it does use that, if not, allow me to enter it
manually.

So, I set it up with the GotFocus event of the dropdown list. Now when I tab
through the dropdowns, I get to the Emp. Number. It tries to grab the
number in the textbox, but I get the Error 2185 'You can't reference a
property or method for a control unless the control has the focus'

So I give the textbox focus, it seems to fix the error, but now when I try
to enter that number into the Dropdown list it says that need focus, so I
setfocus, but now it puts me into an infinite loop.

Any ideas?
Chad
 
J

John Spencer MVP

Don't use the TEXT property of the control. Use the value property of the
control. The text property is only available when the control has the focus.

So
ME.ComboboxName.Value = "Sampson"
will work to assign that value to the combobox whether or not it has the
focus. And since Value is the default property for most data entry controls
you can use
Me.ComboboxName = "Sampson"
and Access will "understand" that you are referring to the value property of
the combobox control.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
C

Chad Cameron

Thanks, that worked great
Chad


John Spencer MVP said:
Don't use the TEXT property of the control. Use the value property of the
control. The text property is only available when the control has the
focus.

So
ME.ComboboxName.Value = "Sampson"
will work to assign that value to the combobox whether or not it has the
focus. And since Value is the default property for most data entry
controls you can use
Me.ComboboxName = "Sampson"
and Access will "understand" that you are referring to the value property
of the combobox control.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

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