error problem

G

Guest

Hi, I am having a recurring problem with one of my forms. When I open it, I
get a message that says: Run-time error '2455': You entered an expression
that has an invalid reference to the property Form/Report.

When I debug, it goes to this line:

Forms![frm_TubesAfterInspection]![frm_TubesToSell subform1]![Material
Transfer Number2].ColumnHidden = -1

This is basically a field in one of three subforms that I don't want showing
up (in datasheet view). The form names are all correct and the form field is
correct is well. I have a form basically identical to this with the same code
etc. that has no problems...any help would be great!
 
D

Douglas J. Steele

To refer to a control on a subform, you use:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform

Note that depending on how you added the form as a subform, the name of the
subform control on the parent form may be different than the name of the
form being used as a subform.

For more information about referring to controls on subforms, check
http://www.mvps.org/access/forms/frm0031.htm at "The Access Web".
 
G

Guest

Thank you, this link is awesome and very helpful
I think I figured out the reason I got the error, but would like your help
on fixing it. Not sure why it happened, but you probably will :)

I was messing around with stuff to try and fix it and remembered I had
deleted all my records in my tables (since I am still in the testing phase
for this database). The form that was having the problems populates based on
a query of a table (all records in the table that are marked as in
inspection). So, to fix the problems, I added a record so that there would be
one shown as in inspection and the problem was fine...even the way I have
coded it. I guess the reason it was giving me the error is since the query
would have given nothing, I would have been given just a blank form without
the subform, thus it could not find the subform field I was hiding???? Thats
a guess.

So, I guess I have two questions:
1) If the way I have it coded works, can I keep it that way or would you
suggest me to fix it. Like I said, I have three subforms and when the query
has something in it, the subforms/form works fine (hides the field) even
though the coding doesn't match that provided in the link and your
explanation.

2) How can I fix this problem such that if the query doesn't return
anything, the user won't get this debugging error. It is highly possible no
parts will be in inspection and if the go to this form, they'll not know what
to do.'

Thanks for the help and the link!


1) Is it okay to keep the code like I have it
2) Is there some code to put in so that if for some reason there are no
records (which could happen given the
--
Michael


Douglas J. Steele said:
To refer to a control on a subform, you use:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform

Note that depending on how you added the form as a subform, the name of the
subform control on the parent form may be different than the name of the
form being used as a subform.

For more information about referring to controls on subforms, check
http://www.mvps.org/access/forms/frm0031.htm at "The Access Web".

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michael said:
Hi, I am having a recurring problem with one of my forms. When I open it,
I
get a message that says: Run-time error '2455': You entered an expression
that has an invalid reference to the property Form/Report.

When I debug, it goes to this line:

Forms![frm_TubesAfterInspection]![frm_TubesToSell subform1]![Material
Transfer Number2].ColumnHidden = -1

This is basically a field in one of three subforms that I don't want
showing
up (in datasheet view). The form names are all correct and the form field
is
correct is well. I have a form basically identical to this with the same
code
etc. that has no problems...any help would be great!
 
D

Douglas J. Steele

1) Is it okay to keep the code like I have it

You should code it properly, even if it's working today. Access sometimes
"tightens up", and stops recognizing incorrect syntax.

2) Is there some code to put in so that if for some reason there are no
records

Try checking the subform's Recordset's RecordCount property:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form.Recordset.RecordCount


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michael said:
Thank you, this link is awesome and very helpful
I think I figured out the reason I got the error, but would like your help
on fixing it. Not sure why it happened, but you probably will :)

I was messing around with stuff to try and fix it and remembered I had
deleted all my records in my tables (since I am still in the testing phase
for this database). The form that was having the problems populates based
on
a query of a table (all records in the table that are marked as in
inspection). So, to fix the problems, I added a record so that there would
be
one shown as in inspection and the problem was fine...even the way I have
coded it. I guess the reason it was giving me the error is since the query
would have given nothing, I would have been given just a blank form
without
the subform, thus it could not find the subform field I was hiding????
Thats
a guess.

So, I guess I have two questions:
1) If the way I have it coded works, can I keep it that way or would you
suggest me to fix it. Like I said, I have three subforms and when the
query
has something in it, the subforms/form works fine (hides the field) even
though the coding doesn't match that provided in the link and your
explanation.

2) How can I fix this problem such that if the query doesn't return
anything, the user won't get this debugging error. It is highly possible
no
parts will be in inspection and if the go to this form, they'll not know
what
to do.'

Thanks for the help and the link!


1) Is it okay to keep the code like I have it
2) Is there some code to put in so that if for some reason there are no
records (which could happen given the
--
Michael


Douglas J. Steele said:
To refer to a control on a subform, you use:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform

Note that depending on how you added the form as a subform, the name of
the
subform control on the parent form may be different than the name of the
form being used as a subform.

For more information about referring to controls on subforms, check
http://www.mvps.org/access/forms/frm0031.htm at "The Access Web".

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michael said:
Hi, I am having a recurring problem with one of my forms. When I open
it,
I
get a message that says: Run-time error '2455': You entered an
expression
that has an invalid reference to the property Form/Report.

When I debug, it goes to this line:

Forms![frm_TubesAfterInspection]![frm_TubesToSell subform1]![Material
Transfer Number2].ColumnHidden = -1

This is basically a field in one of three subforms that I don't want
showing
up (in datasheet view). The form names are all correct and the form
field
is
correct is well. I have a form basically identical to this with the
same
code
etc. that has no problems...any help would be great!
 
G

Guest

Okay, that worked.
As far as the correct coding goes, throughout my DB, I have used notation
such as command37.enabled = true rather than me!command37.enabled=true. Do
you feel this is also necessary to change? The reason is because this would
be quite a large task given the size of this database, but I want to make
sure it is going to work well...thanks again for the help!
--
Michael


Douglas J. Steele said:
1) Is it okay to keep the code like I have it

You should code it properly, even if it's working today. Access sometimes
"tightens up", and stops recognizing incorrect syntax.

2) Is there some code to put in so that if for some reason there are no
records

Try checking the subform's Recordset's RecordCount property:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form.Recordset.RecordCount


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michael said:
Thank you, this link is awesome and very helpful
I think I figured out the reason I got the error, but would like your help
on fixing it. Not sure why it happened, but you probably will :)

I was messing around with stuff to try and fix it and remembered I had
deleted all my records in my tables (since I am still in the testing phase
for this database). The form that was having the problems populates based
on
a query of a table (all records in the table that are marked as in
inspection). So, to fix the problems, I added a record so that there would
be
one shown as in inspection and the problem was fine...even the way I have
coded it. I guess the reason it was giving me the error is since the query
would have given nothing, I would have been given just a blank form
without
the subform, thus it could not find the subform field I was hiding????
Thats
a guess.

So, I guess I have two questions:
1) If the way I have it coded works, can I keep it that way or would you
suggest me to fix it. Like I said, I have three subforms and when the
query
has something in it, the subforms/form works fine (hides the field) even
though the coding doesn't match that provided in the link and your
explanation.

2) How can I fix this problem such that if the query doesn't return
anything, the user won't get this debugging error. It is highly possible
no
parts will be in inspection and if the go to this form, they'll not know
what
to do.'

Thanks for the help and the link!


1) Is it okay to keep the code like I have it
2) Is there some code to put in so that if for some reason there are no
records (which could happen given the
--
Michael


Douglas J. Steele said:
To refer to a control on a subform, you use:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform

Note that depending on how you added the form as a subform, the name of
the
subform control on the parent form may be different than the name of the
form being used as a subform.

For more information about referring to controls on subforms, check
http://www.mvps.org/access/forms/frm0031.htm at "The Access Web".

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi, I am having a recurring problem with one of my forms. When I open
it,
I
get a message that says: Run-time error '2455': You entered an
expression
that has an invalid reference to the property Form/Report.

When I debug, it goes to this line:

Forms![frm_TubesAfterInspection]![frm_TubesToSell subform1]![Material
Transfer Number2].ColumnHidden = -1

This is basically a field in one of three subforms that I don't want
showing
up (in datasheet view). The form names are all correct and the form
field
is
correct is well. I have a form basically identical to this with the
same
code
etc. that has no problems...any help would be great!
 
D

Douglas J. Steele

Personally, I think you should. When you go back to do maintenance on your
application in a few weeks, having the Me! will allow you to be certain
you're talking about a control on the form, rather than a variable.

It's your decision, though.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Michael said:
Okay, that worked.
As far as the correct coding goes, throughout my DB, I have used notation
such as command37.enabled = true rather than me!command37.enabled=true. Do
you feel this is also necessary to change? The reason is because this
would
be quite a large task given the size of this database, but I want to make
sure it is going to work well...thanks again for the help!
--
Michael


Douglas J. Steele said:
1) Is it okay to keep the code like I have it

You should code it properly, even if it's working today. Access sometimes
"tightens up", and stops recognizing incorrect syntax.

2) Is there some code to put in so that if for some reason there are no
records

Try checking the subform's Recordset's RecordCount property:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form.Recordset.RecordCount


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michael said:
Thank you, this link is awesome and very helpful
I think I figured out the reason I got the error, but would like your
help
on fixing it. Not sure why it happened, but you probably will :)

I was messing around with stuff to try and fix it and remembered I had
deleted all my records in my tables (since I am still in the testing
phase
for this database). The form that was having the problems populates
based
on
a query of a table (all records in the table that are marked as in
inspection). So, to fix the problems, I added a record so that there
would
be
one shown as in inspection and the problem was fine...even the way I
have
coded it. I guess the reason it was giving me the error is since the
query
would have given nothing, I would have been given just a blank form
without
the subform, thus it could not find the subform field I was hiding????
Thats
a guess.

So, I guess I have two questions:
1) If the way I have it coded works, can I keep it that way or would
you
suggest me to fix it. Like I said, I have three subforms and when the
query
has something in it, the subforms/form works fine (hides the field)
even
though the coding doesn't match that provided in the link and your
explanation.

2) How can I fix this problem such that if the query doesn't return
anything, the user won't get this debugging error. It is highly
possible
no
parts will be in inspection and if the go to this form, they'll not
know
what
to do.'

Thanks for the help and the link!


1) Is it okay to keep the code like I have it
2) Is there some code to put in so that if for some reason there are no
records (which could happen given the
--
Michael


:

To refer to a control on a subform, you use:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform

Note that depending on how you added the form as a subform, the name
of
the
subform control on the parent form may be different than the name of
the
form being used as a subform.

For more information about referring to controls on subforms, check
http://www.mvps.org/access/forms/frm0031.htm at "The Access Web".

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi, I am having a recurring problem with one of my forms. When I
open
it,
I
get a message that says: Run-time error '2455': You entered an
expression
that has an invalid reference to the property Form/Report.

When I debug, it goes to this line:

Forms![frm_TubesAfterInspection]![frm_TubesToSell
subform1]![Material
Transfer Number2].ColumnHidden = -1

This is basically a field in one of three subforms that I don't want
showing
up (in datasheet view). The form names are all correct and the form
field
is
correct is well. I have a form basically identical to this with the
same
code
etc. that has no problems...any help would be great!
 

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