Cannot reference control

G

Guest

When trying to set a variable or a control property to the value held in another control, sometimes on another open form, I get this error message.

Run-time error ‘2185â€
You can’t reference a property or method for a control unless the control has the focus

This can be solved using SetFocus – except when the control is invisible

I am using Office System 2003 – and I have only limited experience with developing and coding Access forms.

But I am having so many problems (see below), I feel that either there are major differences from earlier Access versions or there is a setting somewhere that I haven’t made. Is it a ‘security’ issue

Other problems
OpenArgs – trying to open form with OpenArgs doesn’t work – OpenArgs is null
ListBox – Checking for .Selected on AfterUpdate doesn’t find any item selected (but it does work if I programmatically set Selected=True for an item). Using ListIndex does work

Just what is going on?
 
A

Allen Browne

Do not use the Text property of the control, e.g. use:
Forms![MyForm]![MyTextbox] = "xxx"
not:
Forms![MyForm]![MyTextbox].Text = "xxx"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.
Mickmq said:
When trying to set a variable or a control property to the value held in
another control, sometimes on another open form, I get this error message.
Run-time error '2185'
You can't reference a property or method for a control unless the control has the focus.

This can be solved using SetFocus - except when the control is invisible.

I am using Office System 2003 - and I have only limited experience with
developing and coding Access forms.
But I am having so many problems (see below), I feel that either there are
major differences from earlier Access versions or there is a setting
somewhere that I haven't made. Is it a 'security' issue?
Other problems:
OpenArgs - trying to open form with OpenArgs doesn't work - OpenArgs is null.
ListBox - Checking for .Selected on AfterUpdate doesn't find any item
selected (but it does work if I programmatically set Selected=True for an
item). Using ListIndex does work.
 

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