Question involving the #Name? Error

C

Cameron P

I copied and pasted some boxes from one form to another, but they are showing
me the "#Name?" error instead of the data. Should I remake the boxes instead
of copying them, or is there something I am forgetting to do? Thanks!
 
F

fredg

I copied and pasted some boxes from one form to another, but they are showing
me the "#Name?" error instead of the data. Should I remake the boxes instead
of copying them, or is there something I am forgetting to do? Thanks!

Controls show a "#Name " error when the field used in it's control
source cannot be found.
For example, if you copied a control whose control source was
"Address", and your new form's record source did not include a field
named "Address", the control would show that error. Just change the
control source to the correct field name.
 
C

Cameron P

Thanks for the help. I still cannot figure this out though. While my source
for the form is one table, is it possible to then have controls based off of
a separate table? For instance, let's say I base my form off of Event Info
table, and I want to add just a few controls to my form from a separate table
titled Store Info...After reading your response, I think this is the reason I
am getting the #Name? error. Is there a way to allow a form to be based off
of one table, while still using a second table to add a few controls?
 
F

fredg

Thanks for the help. I still cannot figure this out though. While my source
for the form is one table, is it possible to then have controls based off of
a separate table? For instance, let's say I base my form off of Event Info
table, and I want to add just a few controls to my form from a separate table
titled Store Info...After reading your response, I think this is the reason I
am getting the #Name? error. Is there a way to allow a form to be based off
of one table, while still using a second table to add a few controls?

Yes, but you need to use DLookUp.
If the name of the table this field is in is "tblMyTable" and the
field in that table is named "MyField" and the table has just the one
record, use:
=DLookUp("[MyField]","tblMyTable")

However, if the tblMyTable has many records, then you need to use a
Where clause to get the correct record.
Look up, in VBA help, DLookUp as well as
Where Clause + Restrict data to a subset of records.

Make sure you use an unbound control and that the name of this control
is not the same as the name of any field used in it's control source
expression, i.e. the name of this control must not be "MyField".
 
C

Cameron P

So, I have used your advice, and the help from Access, and it won't work.
For the first field I am trying to bring over from another table that my form
is not based on, it is a check box that tells me whether or not the Store is
a New Member or not. This info is in a table titled Show Stores. The Field
is NewMember. So, I have tried the expression: =DLookup("[NewMember]", "Show
Stores")...and it is not working. I don't think I need to use the criteria
function, so I just did not add it to the expression...any ideas? Thanks.
 
C

Cameron P

As well, when I enter that expression, and change to the worksheet view, it
gives me a gray check box instead of a clear box or a checked box...it should
be checked if the Show Stores table's field, titled NewMember, has a check
box for that particular store...hopefully this makes sense.

fredg said:
Thanks for the help. I still cannot figure this out though. While my source
for the form is one table, is it possible to then have controls based off of
a separate table? For instance, let's say I base my form off of Event Info
table, and I want to add just a few controls to my form from a separate table
titled Store Info...After reading your response, I think this is the reason I
am getting the #Name? error. Is there a way to allow a form to be based off
of one table, while still using a second table to add a few controls?

Yes, but you need to use DLookUp.
If the name of the table this field is in is "tblMyTable" and the
field in that table is named "MyField" and the table has just the one
record, use:
=DLookUp("[MyField]","tblMyTable")

However, if the tblMyTable has many records, then you need to use a
Where clause to get the correct record.
Look up, in VBA help, DLookUp as well as
Where Clause + Restrict data to a subset of records.

Make sure you use an unbound control and that the name of this control
is not the same as the name of any field used in it's control source
expression, i.e. the name of this control must not be "MyField".
 
R

Rick Brandt

Cameron said:
As well, when I enter that expression, and change to the worksheet
view, it gives me a gray check box instead of a clear box or a
checked box...it should be checked if the Show Stores table's field,
titled NewMember, has a check box for that particular
store...hopefully this makes sense.

If it's "for that particular store" then you DO need the criteria argument
to tell it which store.
 
C

Cameron P

Hmm...well I need the form to display the check mark from the corresponding
table if the store IS a New Member...but I guess I don't understand the
criteria part of the expression. For each record on the form, when I scroll
through, I want it to bring up the box for each store and have it checked or
unchecked depending on what the foreign table says.

So far the only part of the expression that I understand (though it's not
working) is:
=DLookup("[NewMember]","Show Stores")

with NewMember being the field on the foreign table, and Show Stores being
the foreign table...where does criteria come into play? The "Show Stores"
table has approximately 102 different records, and I believe 6 fields...so,
how exactly would the criteria fit into the expression? Thanks!
 
R

Rick Brandt

Cameron said:
Hmm...well I need the form to display the check mark from the
corresponding table if the store IS a New Member...but I guess I
don't understand the criteria part of the expression. For each
record on the form, when I scroll through, I want it to bring up the
box for each store and have it checked or unchecked depending on what
the foreign table says.

So far the only part of the expression that I understand (though it's
not working) is:
=DLookup("[NewMember]","Show Stores")

with NewMember being the field on the foreign table, and Show Stores
being the foreign table...where does criteria come into play? The
"Show Stores" table has approximately 102 different records, and I
believe 6 fields...so, how exactly would the criteria fit into the
expression? Thanks!

Well if Show Stores has 102 different records then which one of those do you
want? THAT determines what the criteria needs to be. If you supply no criteria
then the DLookup() should still work, but you will just get the first record
retrieved in an arbitrary order. If you get nothing then you either have the
field name spelled wrong or the table name spelled wrong OR the first value it
is finding is Null so that is what you are getting.
 
Top