#name? error in form field (1 Viewer)

depawl52

New member
Local time
Today, 05:08
Joined
Feb 8, 2022
Messages
22
So I have a simple query where I want to count the number of (for example) orders and take the average of the cost of the orders.
The query runs fine, but when I create a form based on the query, the count field is OK, but in the average field a #name? error is displayed.
I've verified that the field name in the form is not the same as the control source name. If I instead change the query to a make table query, and
then use the table as the control source of the from it displays OK. I've checked all the formatting, etc. and searched online but have come
up with no solution as yet. Thanks.
 

jdraw

Super Moderator
Staff member
Local time
Today, 05:08
Joined
Jan 23, 2006
Messages
15,361
How about posting your query sql? and your table designs or relationships window with all tables expanded to show all fields. A screen shot of your form may help alp.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:08
Joined
Feb 19, 2013
Messages
16,553
I've verified that the field name in the form is not the same as the control source name
but they should be the same? The controlsource binds the control to the field. Or is 'not' a typo?
 

depawl52

New member
Local time
Today, 05:08
Joined
Feb 8, 2022
Messages
22
So the issue was apparently due to some blank records in a field in the table. Entering zero values in this field appears to have solved the problem.
Thanks.
 

jdraw

Super Moderator
Staff member
Local time
Today, 05:08
Joined
Jan 23, 2006
Messages
15,361
You may have solved the issue, but for those who may follow or stumble upon this thread, it would be helpful if you would show readers your table design(s) and the SQL involved. It isn't obvious (to me at least) the real issue and your solution.

Also, you didn't address CJ's question in post #3.
 

depawl52

New member
Local time
Today, 05:08
Joined
Feb 8, 2022
Messages
22
So as stated above I thought I was able to fix the error by entering some data in blank records in the table, but unfortunately removing said data does not make the error reappear. So I've been unable to recreate the error. If I can figure out how to get the error to reappear I will upload the data. In response to CJ's question above, since I can't get the error to reappear, I can't recall the exact error message but when I Googled that error message before, most of the responses I found indicated that the error is caused by the name of the text box on the form being the same as the name of the field in the source table.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:08
Joined
Feb 28, 2001
Messages
26,996
The #name error occurs when something in the field (that displays that error) is spelled wrong or does not exist or should have been qualified with a location but was not. In essence, Access is saying "I can't find that."

Something to remember is that SQL and form code are two different contexts. SQL runs in context of the ACE database engine, but VBA runs in the context of the Access User Interface. Generally, SQL can't see everything that VBA can see. Just remember that even for VBA code, when you talk about / code about a field in a bound form, that field is part of a recordset so is in SQL context. SQL cannot see variables. (Which is why SQL allows you to create and assign values to SQL parameters, among other things.
 

Users who are viewing this thread

Top Bottom