#Name? displayed in a text box (Access 2003)

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

Guest

I have an error that is driving me nuts...
I have an unbound form in which I want to display the results of a query in
a textbox. The query evaluates correctly, but the textbox displays #Name?
instead of the value from the query. What is going on?

I apologize if this seems a silly question as I am a learning Access.

Thanks in advance!
 
I have an error that is driving me nuts...
I have an unbound form in which I want to display the results of a query in
a textbox. The query evaluates correctly, but the textbox displays #Name?
instead of the value from the query. What is going on?

I apologize if this seems a silly question as I am a learning Access.

Thanks in advance!

And the actual control source of the unbound text box is ....?
And the name of the unbound text box is ....?
 
I have an error that is driving me nuts...
I have an unbound form in which I want to display the results of a query in
a textbox. The query evaluates correctly, but the textbox displays #Name?
instead of the value from the query. What is going on?

I apologize if this seems a silly question as I am a learning Access.

Thanks in advance!

The Control Source property of the textbox should be EITHER the name
of a field in the Form's Recordsource query; OR an expression in its
own right, preceded by an equals sign, e.g.

=[ThisField] + [ThatField];

OR a Domain Function call to look up the value from a query:

=DLookUp("[ResultField]", "[QueryName]", "optional criteria string")

My guess is that you're just putting the name of the query, or
queryname.fieldname, in the control source: that will NOT work.

John W. Vinson[MVP]
 
You hit the nail on the head. I was using the queryname.fieldname in the
control source. I will try the dlookup function. The problem I'm trying to
solve is a wierd one, you can read on if your intrested...

I'm sure there is a more elegant way to do this, but here goes...
What I'm trying to do is display multiple records on one form. I'm easily
able to do that by setting a form's (bound to a query) default view to
Continuous Forms. The problem is that in the query results I'm trying to
display, I need to show the records in a custom sort order. The records
returned from the query have three primary keys, TrayName(text),
ColNumber(integer), and
RowNumber(integer). When I display the records for a particular TrayName, I
need them sorted by the ColNumber, then the RowNumber. The tricky part is
that on odd number rows, the columns must be sorted Ascending (1-6) and on
even rows the columns must be sorted decending (6-1). (This is the way users
will enter data, and is based on how the users generate the readings from a
microscope tray. It's called serpentine reading.) I can't figure a way to
do this in reports or forms with the built in Access sort orders, so...

To get around this problem, I tried creating an unbound form, and dropping
individual textboxes on it. Then I generated unique queries for each well on
the tray (96 of them) and tried to link the Record Source property for each
textbox to the appropriate query. The queries work fine, but the text boxes
on the form just display "#Name?".

For example: the textbox (Text2) that is supposed to display Row1, Column1
for the selected tray has the following query as its control source:
=Trayr1c1!ABOCtr. That query looks like this: SELECT [Prelim 180
Query].CellTxt, [Prelim 180 Query].ABOCtr
FROM [Prelim 180 Query]
WHERE ((([Prelim 180 Query].TrayNm)=[Forms]![Navigator]![TraySelect]) AND
(([Prelim 180 Query].RowNbr)=1) AND (([Prelim 180 Query].ColNbr)=1));

I've been trying to figure this out for DAYS...any suggestions would be
greatly appreciated.

Peace,
OldStoneBuddha


John Vinson said:
I have an error that is driving me nuts...
I have an unbound form in which I want to display the results of a query in
a textbox. The query evaluates correctly, but the textbox displays #Name?
instead of the value from the query. What is going on?

I apologize if this seems a silly question as I am a learning Access.

Thanks in advance!

The Control Source property of the textbox should be EITHER the name
of a field in the Form's Recordsource query; OR an expression in its
own right, preceded by an equals sign, e.g.

=[ThisField] + [ThatField];

OR a Domain Function call to look up the value from a query:

=DLookUp("[ResultField]", "[QueryName]", "optional criteria string")

My guess is that you're just putting the name of the query, or
queryname.fieldname, in the control source: that will NOT work.

John W. Vinson[MVP]
 
edMr. Vinson,

THANK YOU!!! That solved it. I put the following in my control source:
=DLookUp("[CellTxt]","[Prelim 180 Query]","[RowNbr] = 1 AND [ColNbr] =1")
and viola! You have helped me a great deal, and you have my gratitude. My
problem is that I am a old EXCEL user & VB person who is now realizing the
great benefits of ACCESS. However, some skills don't port over well to
ACCESS. In VB, I could just set the textbox field's Value property to
whatever I wanted. ACCESS has some stricter rules...but I will learn.
Again, Thank You!

Peace,

Scott D. Collins, CHS(ABHI)
Laboratories At Bonfils
Denver, CO
work: (e-mail address removed)
home: (e-mail address removed)

John Vinson said:
I have an error that is driving me nuts...
I have an unbound form in which I want to display the results of a query in
a textbox. The query evaluates correctly, but the textbox displays #Name?
instead of the value from the query. What is going on?

I apologize if this seems a silly question as I am a learning Access.

Thanks in advance!

The Control Source property of the textbox should be EITHER the name
of a field in the Form's Recordsource query; OR an expression in its
own right, preceded by an equals sign, e.g.

=[ThisField] + [ThatField];

OR a Domain Function call to look up the value from a query:

=DLookUp("[ResultField]", "[QueryName]", "optional criteria string")

My guess is that you're just putting the name of the query, or
queryname.fieldname, in the control source: that will NOT work.

John W. Vinson[MVP]
 
The records
returned from the query have three primary keys, TrayName(text),
ColNumber(integer), and RowNumber(integer).

Jargon nitpick: you have ONE Primary Key consisting of three fields.
The primary key is by definition unique - <Highlander.There Can Only
Be One said:
When I display the records for a particular TrayName, I
need them sorted by the ColNumber, then the RowNumber. The tricky part is
that on odd number rows, the columns must be sorted Ascending (1-6) and on
even rows the columns must be sorted decending (6-1). (This is the way users
will enter data, and is based on how the users generate the readings from a
microscope tray. It's called serpentine reading.) I can't figure a way to
do this in reports or forms with the built in Access sort orders, so...

Ok... put a calculated field in the Query:

SortCol: IIf([RowNumber] MOD 2 = 0, 7 - [ColNumber], [ColNumber])

and sort by TrayName, SortCol, and RowNumber.

Glad to be able to help!

John W. Vinson[MVP]
 
Back
Top