Source of text box says "#Name?"

S

So Call Me Crazy

This is really silly. I have a text box. I want to default value of the
text box to be the result of a query that will return only 1 value. And what
I get is "#Name?"

For example, I have a short table that has folks' logon IDs and their
corresponding full name. I have the code that gets a person's logon ID.
That's working fine. I have a query that uses that function and returns the
correct person's full name. But, when I use that query as the default value
of the text box, I get the garbage above.

What am I doing wrong?
 
S

strive4peace

You cannot use a query directly as the Controlsource of a textbox --
even if it only returns one value

instead, use dFirst

controlSource --> =dFirst("[columnname]","[Queryname]")


Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
S

So Call Me Crazy

Well, not sure what it didn't care for, but I needed to change it up a bit.
Here's what worked:

=DFirst("[columnName]","[TableName]","the WHERE portion of the SQL code
behind the query")

Thanks for steering me in the right direction!

strive4peace said:
You cannot use a query directly as the Controlsource of a textbox --
even if it only returns one value

instead, use dFirst

controlSource --> =dFirst("[columnname]","[Queryname]")


Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


This is really silly. I have a text box. I want to default value of the
text box to be the result of a query that will return only 1 value. And what
I get is "#Name?"

For example, I have a short table that has folks' logon IDs and their
corresponding full name. I have the code that gets a person's logon ID.
That's working fine. I have a query that uses that function and returns the
correct person's full name. But, when I use that query as the default value
of the text box, I get the garbage above.

What am I doing wrong?
 
S

strive4peace

you're welcome ;) it is better to get rid of the query anyway -- and go
straight to the source!

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


Well, not sure what it didn't care for, but I needed to change it up a bit.
Here's what worked:

=DFirst("[columnName]","[TableName]","the WHERE portion of the SQL code
behind the query")

Thanks for steering me in the right direction!

strive4peace said:
You cannot use a query directly as the Controlsource of a textbox --
even if it only returns one value

instead, use dFirst

controlSource --> =dFirst("[columnname]","[Queryname]")


Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


This is really silly. I have a text box. I want to default value of the
text box to be the result of a query that will return only 1 value. And what
I get is "#Name?"

For example, I have a short table that has folks' logon IDs and their
corresponding full name. I have the code that gets a person's logon ID.
That's working fine. I have a query that uses that function and returns the
correct person's full name. But, when I use that query as the default value
of the text box, I get the garbage above.

What am I doing wrong?
 
Top