Error Message

  • Thread starter Thread starter DaveB
  • Start date Start date
D

DaveB

I received this error message.

Run-time error '2465'
Microsoft Access can't find the field 'BOX_Name' referred
to in your expression.

I have a form with two subforms, and in the subforms I
have the same field called 'BOX_NAME'. When I enter
information on the first subform, I it to automatically go
into the second subform.

The code below is not working...TIA for your help.

Private Sub BOX_NAME_AfterUpdate()

Me.Parent!CONTENTS_TABLE_subform.Form!BOX_NAME = Me!
BOX_NAME

End Sub
 
Right off-hand, you're syntax appears to be correct, so a couple of
questions.

1) Where are the two subforms located? Are they both on the main form or is
one a subform of the other subform? The current syntax would be correct if
they are both on the main form.

2) Is CONTENTS_TABLE_subform the name of the subform or the name of the
control that holds the subform? It should be the latter.

3) Check for typos.

4) Since you're using the !, I don't think this is it, but it's worth
checking. Sometimes if the control (i.e. textbox) and the field it is bound
to have the same name, you'll have problems. It is best to rename the
control. For example, if the field name is BOX_Name, then name the textbox
txtBOX_Name. Refer to the textbox in your code. (Do this on both sides of
the equal sign).
 
Hi Dave

In your two posts this morning, you have spelled the name of your control
three different ways:
"BOXNAME" (no space)
"BOX NAME" (space between words)
"BOX_NAME" (underscore between words)

I suggest that spaces in names are A Bad Idea.

You should adopt one of the following conventions and stick to it:
a) Underscores between words: "box_name"
b) "Camel Case" with no spaces: "BoxName"

People who use underscores often use all lowercase. Camel case seems to be
more often used in Access for some reason.

Note also that part of your command below that reads
"CONTENTS_TABLE_subform" should be the name of the subform *control* that
contains the subform, not the name of the subform object contained inside
it. I suggest you name the subform control something like
"sbfContentsTable". Then, your code should look something like this:

Private Sub BoxName_AfterUpdate()
Me.Parent!sbfContentsTable.Form!BoxName = Me!BoxName
End Sub
 
Back
Top