Trick Question

L

Luis

Hello.
I have a form with a subform, and i'm using the vba command bellow to enable
and to unlock a certain control, but i get a run-time error 2455.

The command is
"Forms!MyFormName.MySubformName.Form.Controls!MyControl.Enabled=True"
And the same to Locked=False

What am i doing wrong?
 
D

Dirk Goldgar

Luis said:
Hello.
I have a form with a subform, and i'm using the vba command bellow to
enable and to unlock a certain control, but i get a run-time error
2455.

The command is
"Forms!MyFormName.MySubformName.Form.Controls!MyControl.Enabled=True"
And the same to Locked=False

What am i doing wrong?

Verify that "MySubformName" -- that is, the value you're really using in
this part of the reference -- is really the name of the subform
*control* on the main form, and not just the name of the form object
that the subform control is displaying.
 
L

Luis

Yes, i already checked that.

Dirk Goldgar said:
Verify that "MySubformName" -- that is, the value you're really using in
this part of the reference -- is really the name of the subform
*control* on the main form, and not just the name of the form object
that the subform control is displaying.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
D

Dirk Goldgar

Luis said:
Yes, i already checked that.

What type of control is "MyControl"?

Can I safely assume that the main form is in fact open at the time you
execute this line of code?
 
D

Dirk Goldgar

Luis said:
Found the solution.
Good!

The problem wasn't in the names but on the recordset.

I don't follow you. What recordset? Would you care to explain?
 
L

Luis

The problem was on the recordset that is the recordsource of the form. There
was an error on the SQL command and therefore the run-time error occurs. I've
corrected the SQL command and the form worked perfectly.
The MyControl that i mentioned is a text box that when i load the form is
net enabled and locked.
 
D

Dirk Goldgar

Luis said:
The problem was on the recordset that is the recordsource of the
form. There was an error on the SQL command and therefore the
run-time error occurs. I've corrected the SQL command and the form
worked perfectly.
The MyControl that i mentioned is a text box that when i load the
form is net enabled and locked.

Interesting, because I wouldn't have expected that particular error
under those circumstances. Live and learn. Thanks. for the
explanation.
 

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