# MS Access - #NAME? error



## Deleted member 3 (Sep 1, 2006)

Lately I've been forced to work with MS Access, not quite my own preference but I have no choice here. So I've been learning myself some access, going quite well. THough for the past days I've been frustrated by the #NAME? error. I'm trying to make a textbox which gets its data from a control source, works fine. However I want the default value to be a select max query. I made the query, which works perfectly. When I add the query to the default value field it tells me #NAME? though. Any way of entering the query fails. However, if I make a combobox or listbox and add the query it works just fine. Does anyone here happen to be some MS Access guru or simply know the answer to this issue?


I already found the attached piece of text (couldn't copy it so I made a screeny, damn PDF) it didn't help at all though.


----------



## Alec§taar (Sep 5, 2006)

DanTheBanjoman said:


> Lately I've been forced to work with MS Access, not quite my own preference but I have no choice here. So I've been learning myself some access, going quite well. THough for the past days I've been frustrated by the #NAME? error. I'm trying to make a textbox which gets its data from a control source, works fine. However I want the default value to be a select max query. I made the query, which works perfectly. When I add the query to the default value field it tells me #NAME? though. Any way of entering the query fails. However, if I make a combobox or listbox and add the query it works just fine. Does anyone here happen to be some MS Access guru or simply know the answer to this issue?



There's a COUPLE ways to do this. 

*FIRST OFF:*

When you have a text field, right click on it to assign either macros, vba modules, or functions *OR QUERIES*, iirc, to fill it. 

(There are many "prebuilt functions" you can use on fields/values as well, keep this in mind... but, in your case, depending on the db value for the field being returned that you are interested in, in this recordset? You may not have to use them (data type conversions stuff like InToStr/ToString etc.)):

(Makeshift example of a VBA Module to use, syntax MAY be slightly off)

Option Explicit
Dim VariableName as String
VariableName = QueryName!ColName!Value
TextBox1.Text = variablename

*Using "!" may not be as efficient as possible as well, keep this in mind - using [Recordset].[ColName] may be the best way.*

Also, IF your recordset contains MORE THAN 1 RETURNED VALUE? You may have to "query that query" in a macro possibly, and obtain the SPECIFIC value you wish (LIKE or = help here in the SQL Syntax also).

In other words, have you tried equating your SQLQuery result (assuming single variable answer results) to a var you DIM & then punching it back into the textbox field? You MAY have to make sure it is of STRING type as well 

e.g. ->  IntToStr(VariableName)

(I have NO idea if your returned resultset/recordset is of Int or Str value, but the idea is there, in that you MAY have to convert its datatype to string for your Textbox field)

APK

P.S.=> Show me your query too, in its "SQL VIEW" if you designed it "visually"... 

Admittedly, it's been a LONG while since I worked w/ Access but I am fairly decent @ it... first tool I ever used coding in fact, Access 2.0 - Access 2000 (last time I used it).

You may be able to DIRECTLY feed that textbox field w/ your variable (which I think is what you are up to here, rather than using a separate VAR you DIM to do this & possibly have to convert)... 

Also - I will need the datatype of your recordset return values as well.

Usually, iirc, when it nags you about NAME stuff? It is saying it needs the SPECIFICS, such as Recordset!Col!Value stuff...

Computers are "STUPID" & need exact directions & I THINK this is what it is telling you - it needs to know a SPECIFIC member of a SPECIFIC QUERY returned recordset value... apk


----------

