Run-time error '2424'

G

Guest

I have encountered a problem with some code in Access 2003 after upgrading
from Access '97. In particular this statement:


me.ControlName.Value = [Forms]![Application]![ControlName].Value

I am attempting to assign the value of a control from the parent form to a
sub form.

The exact error displayed is as follows:

Run-time error '2424'
The expression you entered has a field, control, or property name that
Application can't find.

This used to work in Access 97 but not in 2003. Any help would be
appreciated.

Thanks.
 
A

Alex

Hi Mario,

Have you tried to compile the project?

Have you checked your references to make sure that are all there and
none are missing?

Have you tried to compact and repair the database?

Regards

Alex
 
G

Guest

Hi Alex,

Yes i've compiled the project, verified all references (which would have
failed during the compilation process), and compacted and repaired the DB.

Still no luck. In debug mode, i can access certain properties like:

[Forms]![Application]![ControlName].Name
[Forms]![Application]![ControlName].Enabled

but for some reason i cannot access the following two:

[Forms]![Application]![ControlName].Value
[Forms]![Application]![ControlName].Text

For the first one i get error 2424. When i use the second line i get an
error message saying that the control doesn't have focus.

Any ideas?
 
A

Alex

Hi Mario,

the last error message is correct, it is as it says use the 'value'
property rather than 'text' property.

you should be able to use

[Forms]![Application]![Control­Name].Value

but try

Form_Application.myControl.VALUE

Hope it helps

Regards

Alex
 
B

Brendan Reynolds

What type of control is it?

Re the Text property, that's as expected - you have to set the focus to an
Access form control before you can refer to the Text property. If you're
coming from VB, you may expect the Text property to be the default property,
but the Value property is the default property of an Access form control.

--
Brendan Reynolds (MVP)

Mario G. said:
Hi Alex,

Yes i've compiled the project, verified all references (which would have
failed during the compilation process), and compacted and repaired the DB.

Still no luck. In debug mode, i can access certain properties like:

[Forms]![Application]![ControlName].Name
[Forms]![Application]![ControlName].Enabled

but for some reason i cannot access the following two:

[Forms]![Application]![ControlName].Value
[Forms]![Application]![ControlName].Text

For the first one i get error 2424. When i use the second line i get an
error message saying that the control doesn't have focus.

Any ideas?


Alex said:
Hi Mario,

Have you tried to compile the project?

Have you checked your references to make sure that are all there and
none are missing?

Have you tried to compact and repair the database?

Regards

Alex
 
G

Guest

Hi Brendan,

The one control in which we are retrieving the value from is a combo box
control and the assignment control is a text box. Yes I am coming from a VB
background and have taken over this Access project from a former employee who
left the company.


Brendan Reynolds said:
What type of control is it?

Re the Text property, that's as expected - you have to set the focus to an
Access form control before you can refer to the Text property. If you're
coming from VB, you may expect the Text property to be the default property,
but the Value property is the default property of an Access form control.

--
Brendan Reynolds (MVP)

Mario G. said:
Hi Alex,

Yes i've compiled the project, verified all references (which would have
failed during the compilation process), and compacted and repaired the DB.

Still no luck. In debug mode, i can access certain properties like:

[Forms]![Application]![ControlName].Name
[Forms]![Application]![ControlName].Enabled

but for some reason i cannot access the following two:

[Forms]![Application]![ControlName].Value
[Forms]![Application]![ControlName].Text

For the first one i get error 2424. When i use the second line i get an
error message saying that the control doesn't have focus.

Any ideas?


Alex said:
Hi Mario,

Have you tried to compile the project?

Have you checked your references to make sure that are all there and
none are missing?

Have you tried to compact and repair the database?

Regards

Alex
 
B

Brendan Reynolds

OK. Both combo boxes and text boxes certainly do have a Value property. But
wasn't there some mention of a subform in one of the earlier posts? When a
form is being used as the SourceObject of a subform control, that form is
not added to the Forms collection. If you're assigning a value from a
control on a parent form to a control on a subform of that parent form, the
code would look something like ...

Forms!ParentForm!SubformControl.Form!TargetControl =
Forms!ParentForm!SourceControl

If the code is running behind the parent form, you can shorten that to ...

Me!SubformControl.Form!TargetControl = Me!SourceControl

If the code is running behind the subform, I believe you could use ...

Me!TargetControl = Me.Parent!SourceControl

.... but that's from memory, I haven't done that recently enough to be 100%
sure of the syntax.

--
Brendan Reynolds (MVP)

Mario G. said:
Hi Brendan,

The one control in which we are retrieving the value from is a combo box
control and the assignment control is a text box. Yes I am coming from a
VB
background and have taken over this Access project from a former employee
who
left the company.


Brendan Reynolds said:
What type of control is it?

Re the Text property, that's as expected - you have to set the focus to
an
Access form control before you can refer to the Text property. If you're
coming from VB, you may expect the Text property to be the default
property,
but the Value property is the default property of an Access form control.

--
Brendan Reynolds (MVP)

Mario G. said:
Hi Alex,

Yes i've compiled the project, verified all references (which would
have
failed during the compilation process), and compacted and repaired the
DB.

Still no luck. In debug mode, i can access certain properties like:

[Forms]![Application]![ControlName].Name
[Forms]![Application]![ControlName].Enabled

but for some reason i cannot access the following two:

[Forms]![Application]![ControlName].Value
[Forms]![Application]![ControlName].Text

For the first one i get error 2424. When i use the second line i get
an
error message saying that the control doesn't have focus.

Any ideas?


:

Hi Mario,

Have you tried to compile the project?

Have you checked your references to make sure that are all there and
none are missing?

Have you tried to compact and repair the database?

Regards

Alex
 
G

Guest

Yes the code that is causing the problem resides in a sub form.
Me!TargetControl = Me.Parent!SourceControl

I have something similar here where the Me!TargetControl is a Text Box and
the Me.Parent!SourceControl is a combo box.

However when i do this i get a different error:

-2147352567 (80020009)
The value you entered isn't valid for this field.

I have determined that it's complaining about the Me.Parent!SourceControl
reference but don't know exactly why.


Brendan Reynolds said:
OK. Both combo boxes and text boxes certainly do have a Value property. But
wasn't there some mention of a subform in one of the earlier posts? When a
form is being used as the SourceObject of a subform control, that form is
not added to the Forms collection. If you're assigning a value from a
control on a parent form to a control on a subform of that parent form, the
code would look something like ...

Forms!ParentForm!SubformControl.Form!TargetControl =
Forms!ParentForm!SourceControl

If the code is running behind the parent form, you can shorten that to ...

Me!SubformControl.Form!TargetControl = Me!SourceControl

If the code is running behind the subform, I believe you could use ...

Me!TargetControl = Me.Parent!SourceControl

.... but that's from memory, I haven't done that recently enough to be 100%
sure of the syntax.

--
Brendan Reynolds (MVP)

Mario G. said:
Hi Brendan,

The one control in which we are retrieving the value from is a combo box
control and the assignment control is a text box. Yes I am coming from a
VB
background and have taken over this Access project from a former employee
who
left the company.


Brendan Reynolds said:
What type of control is it?

Re the Text property, that's as expected - you have to set the focus to
an
Access form control before you can refer to the Text property. If you're
coming from VB, you may expect the Text property to be the default
property,
but the Value property is the default property of an Access form control.

--
Brendan Reynolds (MVP)

Hi Alex,

Yes i've compiled the project, verified all references (which would
have
failed during the compilation process), and compacted and repaired the
DB.

Still no luck. In debug mode, i can access certain properties like:

[Forms]![Application]![ControlName].Name
[Forms]![Application]![ControlName].Enabled

but for some reason i cannot access the following two:

[Forms]![Application]![ControlName].Value
[Forms]![Application]![ControlName].Text

For the first one i get error 2424. When i use the second line i get
an
error message saying that the control doesn't have focus.

Any ideas?


:

Hi Mario,

Have you tried to compile the project?

Have you checked your references to make sure that are all there and
none are missing?

Have you tried to compact and repair the database?

Regards

Alex
 
B

Brendan Reynolds

The combo box may be bound to a field of one data type but displaying a
field of a different data type from a lookup table. Check the Control
Source, Row Source and Bound Column properties of the combo box.

--
Brendan Reynolds (MVP)

Mario G. said:
Yes the code that is causing the problem resides in a sub form.
Me!TargetControl = Me.Parent!SourceControl

I have something similar here where the Me!TargetControl is a Text Box and
the Me.Parent!SourceControl is a combo box.

However when i do this i get a different error:

-2147352567 (80020009)
The value you entered isn't valid for this field.

I have determined that it's complaining about the Me.Parent!SourceControl
reference but don't know exactly why.


Brendan Reynolds said:
OK. Both combo boxes and text boxes certainly do have a Value property.
But
wasn't there some mention of a subform in one of the earlier posts? When
a
form is being used as the SourceObject of a subform control, that form is
not added to the Forms collection. If you're assigning a value from a
control on a parent form to a control on a subform of that parent form,
the
code would look something like ...

Forms!ParentForm!SubformControl.Form!TargetControl =
Forms!ParentForm!SourceControl

If the code is running behind the parent form, you can shorten that to
...

Me!SubformControl.Form!TargetControl = Me!SourceControl

If the code is running behind the subform, I believe you could use ...

Me!TargetControl = Me.Parent!SourceControl

.... but that's from memory, I haven't done that recently enough to be
100%
sure of the syntax.

--
Brendan Reynolds (MVP)

Mario G. said:
Hi Brendan,

The one control in which we are retrieving the value from is a combo
box
control and the assignment control is a text box. Yes I am coming from
a
VB
background and have taken over this Access project from a former
employee
who
left the company.


:

What type of control is it?

Re the Text property, that's as expected - you have to set the focus
to
an
Access form control before you can refer to the Text property. If
you're
coming from VB, you may expect the Text property to be the default
property,
but the Value property is the default property of an Access form
control.

--
Brendan Reynolds (MVP)

Hi Alex,

Yes i've compiled the project, verified all references (which would
have
failed during the compilation process), and compacted and repaired
the
DB.

Still no luck. In debug mode, i can access certain properties like:

[Forms]![Application]![ControlName].Name
[Forms]![Application]![ControlName].Enabled

but for some reason i cannot access the following two:

[Forms]![Application]![ControlName].Value
[Forms]![Application]![ControlName].Text

For the first one i get error 2424. When i use the second line i
get
an
error message saying that the control doesn't have focus.

Any ideas?


:

Hi Mario,

Have you tried to compile the project?

Have you checked your references to make sure that are all there
and
none are missing?

Have you tried to compact and repair the database?

Regards

Alex
 
G

Guest

Thanks Brendan,

I actually discovered the problem with assigning the value from the parent
form's control to the sub form's control.

The name of the parent form is 'Application' which is a reserved word in
Access. Apparently in Access '97 you were able to use reserved words for
form, control and variable names.

Once I renamed the form to frmApplication all all references, my problem
disappeared.

Thanks for your help and insight.

Mario


Brendan Reynolds said:
The combo box may be bound to a field of one data type but displaying a
field of a different data type from a lookup table. Check the Control
Source, Row Source and Bound Column properties of the combo box.

--
Brendan Reynolds (MVP)

Mario G. said:
Yes the code that is causing the problem resides in a sub form.
Me!TargetControl = Me.Parent!SourceControl

I have something similar here where the Me!TargetControl is a Text Box and
the Me.Parent!SourceControl is a combo box.

However when i do this i get a different error:

-2147352567 (80020009)
The value you entered isn't valid for this field.

I have determined that it's complaining about the Me.Parent!SourceControl
reference but don't know exactly why.


Brendan Reynolds said:
OK. Both combo boxes and text boxes certainly do have a Value property.
But
wasn't there some mention of a subform in one of the earlier posts? When
a
form is being used as the SourceObject of a subform control, that form is
not added to the Forms collection. If you're assigning a value from a
control on a parent form to a control on a subform of that parent form,
the
code would look something like ...

Forms!ParentForm!SubformControl.Form!TargetControl =
Forms!ParentForm!SourceControl

If the code is running behind the parent form, you can shorten that to
...

Me!SubformControl.Form!TargetControl = Me!SourceControl

If the code is running behind the subform, I believe you could use ...

Me!TargetControl = Me.Parent!SourceControl

.... but that's from memory, I haven't done that recently enough to be
100%
sure of the syntax.

--
Brendan Reynolds (MVP)

Hi Brendan,

The one control in which we are retrieving the value from is a combo
box
control and the assignment control is a text box. Yes I am coming from
a
VB
background and have taken over this Access project from a former
employee
who
left the company.


:

What type of control is it?

Re the Text property, that's as expected - you have to set the focus
to
an
Access form control before you can refer to the Text property. If
you're
coming from VB, you may expect the Text property to be the default
property,
but the Value property is the default property of an Access form
control.

--
Brendan Reynolds (MVP)

Hi Alex,

Yes i've compiled the project, verified all references (which would
have
failed during the compilation process), and compacted and repaired
the
DB.

Still no luck. In debug mode, i can access certain properties like:

[Forms]![Application]![ControlName].Name
[Forms]![Application]![ControlName].Enabled

but for some reason i cannot access the following two:

[Forms]![Application]![ControlName].Value
[Forms]![Application]![ControlName].Text

For the first one i get error 2424. When i use the second line i
get
an
error message saying that the control doesn't have focus.

Any ideas?


:

Hi Mario,

Have you tried to compile the project?

Have you checked your references to make sure that are all there
and
none are missing?

Have you tried to compact and repair the database?

Regards

Alex
 
B

Brendan Reynolds

I'm kicking myself, Mario. I actually was going to suggest that the name
might be part of the problem earlier, but the fact that it had been working
with that name before threw me off. I should have remembered that later
versions of Access seem to be more 'picky' about that sort of thing than
earlier versions. Anyhow, glad you got it sorted.

--
Brendan Reynolds (MVP)


Mario G. said:
Thanks Brendan,

I actually discovered the problem with assigning the value from the parent
form's control to the sub form's control.

The name of the parent form is 'Application' which is a reserved word in
Access. Apparently in Access '97 you were able to use reserved words for
form, control and variable names.

Once I renamed the form to frmApplication all all references, my problem
disappeared.

Thanks for your help and insight.

Mario


Brendan Reynolds said:
The combo box may be bound to a field of one data type but displaying a
field of a different data type from a lookup table. Check the Control
Source, Row Source and Bound Column properties of the combo box.

--
Brendan Reynolds (MVP)

Mario G. said:
Yes the code that is causing the problem resides in a sub form.

Me!TargetControl = Me.Parent!SourceControl

I have something similar here where the Me!TargetControl is a Text Box
and
the Me.Parent!SourceControl is a combo box.

However when i do this i get a different error:

-2147352567 (80020009)
The value you entered isn't valid for this field.

I have determined that it's complaining about the
Me.Parent!SourceControl
reference but don't know exactly why.


:

OK. Both combo boxes and text boxes certainly do have a Value
property.
But
wasn't there some mention of a subform in one of the earlier posts?
When
a
form is being used as the SourceObject of a subform control, that form
is
not added to the Forms collection. If you're assigning a value from a
control on a parent form to a control on a subform of that parent
form,
the
code would look something like ...

Forms!ParentForm!SubformControl.Form!TargetControl =
Forms!ParentForm!SourceControl

If the code is running behind the parent form, you can shorten that to
...

Me!SubformControl.Form!TargetControl = Me!SourceControl

If the code is running behind the subform, I believe you could use ...

Me!TargetControl = Me.Parent!SourceControl

.... but that's from memory, I haven't done that recently enough to be
100%
sure of the syntax.

--
Brendan Reynolds (MVP)

Hi Brendan,

The one control in which we are retrieving the value from is a combo
box
control and the assignment control is a text box. Yes I am coming
from
a
VB
background and have taken over this Access project from a former
employee
who
left the company.


:

What type of control is it?

Re the Text property, that's as expected - you have to set the
focus
to
an
Access form control before you can refer to the Text property. If
you're
coming from VB, you may expect the Text property to be the default
property,
but the Value property is the default property of an Access form
control.

--
Brendan Reynolds (MVP)

Hi Alex,

Yes i've compiled the project, verified all references (which
would
have
failed during the compilation process), and compacted and
repaired
the
DB.

Still no luck. In debug mode, i can access certain properties
like:

[Forms]![Application]![ControlName].Name
[Forms]![Application]![ControlName].Enabled

but for some reason i cannot access the following two:

[Forms]![Application]![ControlName].Value
[Forms]![Application]![ControlName].Text

For the first one i get error 2424. When i use the second line i
get
an
error message saying that the control doesn't have focus.

Any ideas?


:

Hi Mario,

Have you tried to compile the project?

Have you checked your references to make sure that are all there
and
none are missing?

Have you tried to compact and repair the database?

Regards

Alex
 

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