What does "#Name?" mean in a form field?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am very unsuccessfully attempting to use DLookUp to automatically fill a
field on a form based on the contents of the field that is selected from a
combo box on the same form.

This is my expression:

=DLookUp([MaintenanceItems!Price],[MaintenanceItems],[MaintenanceItems!Item]=[Item])

I used the expression builder to create it. The final "[Item]" is the field
on the form that I want to compare to the field in the table. (I was
expecting it to say something like
"[Forms]![MainForm]![TabControlName]![Item]" but expression builder seems to
think otherwise!)

Anyway, it doesn't matter whether I keep it the same as expression builder
creates it or add in the extra bits, I still get the "#Name?" in the field
that I want automatically filled.

Can somebody tell me where I have gone wrong?

Thanks!

Ali
 
#Name is Access's way of saying "I don't know what you want". It could be a
mispelled field, an unknown function or incorrect syntax.

Assuming you are trying to get the value of the Price Field from the table
MaintenanceItems where Item (in the table) = Item (in the current form),
Try
=DLookUp("[Price]","MaintenanceItems","[Item] = '" & Item & "'")

The field and table names in the 1st 2 arguments require quotations, as does
the "static" part of the 3rd argument (the criteria)
When using Dlookup, I generally make sure Field names are bracketed and that
table names are not. That seems to be how the help entry examples are
written and has always worked pretty well for me.
(I was
expecting it to say something like
"[Forms]![MainForm]![TabControlName]![Item]" but expression builder seems
to
think otherwise!)

i.e., the Forms!MainForm.Controls collection includes both the tab control
and any controls that appear to reside on the tab control. The tab control
does *not* have its own Controls collection (since it isn't a Form). I know
that this might seem a bit contrary to what you are seeing, but that's the
way it's organized.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


MeWivFree said:
I am very unsuccessfully attempting to use DLookUp to automatically fill a
field on a form based on the contents of the field that is selected from a
combo box on the same form.

This is my expression:

=DLookUp([MaintenanceItems!Price],[MaintenanceItems],[MaintenanceItems!Item]=[Item])

I used the expression builder to create it. The final "[Item]" is the
field
on the form that I want to compare to the field in the table. (I was
expecting it to say something like
"[Forms]![MainForm]![TabControlName]![Item]" but expression builder seems
to
think otherwise!)

Anyway, it doesn't matter whether I keep it the same as expression builder
creates it or add in the extra bits, I still get the "#Name?" in the field
that I want automatically filled.

Can somebody tell me where I have gone wrong?

Thanks!

Ali
 
I am very unsuccessfully attempting to use DLookUp to automatically fill a
field on a form based on the contents of the field that is selected from a
combo box on the same form.

This is my expression:

=DLookUp([MaintenanceItems!Price],[MaintenanceItems],[MaintenanceItems!Item]=[Item])

I used the expression builder to create it. The final "[Item]" is the field
on the form that I want to compare to the field in the table. (I was
expecting it to say something like
"[Forms]![MainForm]![TabControlName]![Item]" but expression builder seems to
think otherwise!)

Anyway, it doesn't matter whether I keep it the same as expression builder
creates it or add in the extra bits, I still get the "#Name?" in the field
that I want automatically filled.

Can somebody tell me where I have gone wrong?

Thanks!

Ali

1) Each argument in the DLookUp must be a string expression (enclosed
within quotes).
Also, the Where Clause expression is written differently depending
upon the Datatype of the field to be compared to.

What is the datatype of the Item field in the table?
If it is a Number, then use:

=DLookUp("[Price]","MaintenanceItems]","[Item] = " & [Item])

However, if Item is a Text datatype, then use:
=DLookUp("[Price]","MaintenanceItems]","[Item] = '" & [Item] & "'")

2) Make sure the bound column of the combo box matches the datatype
of the [Item] field in the table.

3) Also make sure the name of this control is not the same as the
name of any field used within it's control source expression.
 
Back
Top