How to fill a textbox with text and query result

R

Rob

Hello,

I want the user to know the category they are adding a record to by a text
box on a form.
If I put the control source of the text box as ="record is added to" & " "
I get the text plus a space. How do I add in the query result?

I tried
="record is added to" & " " & [qrytest].[subphasename]
="record is added to" & " " & [qrytest]![subphasename]
="record is added to" & " " & ([qrytest.subphasename])

I get the #Name error.
If I run the query it shows correctly, but I am missing something in the
syntax apparently.

thanks,
Rob
 
M

Marshall Barton

Rob said:
Hello,

I want the user to know the category they are adding a record to by a text
box on a form.
If I put the control source of the text box as ="record is added to" & " "
I get the text plus a space. How do I add in the query result?

I tried
="record is added to" & " " & [qrytest].[subphasename]
="record is added to" & " " & [qrytest]![subphasename]
="record is added to" & " " & ([qrytest.subphasename])

I get the #Name error.
If I run the query it shows correctly, but I am missing something in the
syntax apparently.


To get a value from a table/query, you have to open a
recordset. An easy way to retrive a single value is to use
the DLookup function which does that for you.

="record is added to " & DLookup("subphasename","qrytest")

That's probably not going to get what you want, but you
didn't explain enough for me to figure out what else you may
need to do.
 
R

Rob

Actually that works perfectly.
Thanks for the training.

Rob

Marshall Barton said:
Rob said:
Hello,

I want the user to know the category they are adding a record to by a text
box on a form.
If I put the control source of the text box as ="record is added to" & " "
I get the text plus a space. How do I add in the query result?

I tried
="record is added to" & " " & [qrytest].[subphasename]
="record is added to" & " " & [qrytest]![subphasename]
="record is added to" & " " & ([qrytest.subphasename])

I get the #Name error.
If I run the query it shows correctly, but I am missing something in the
syntax apparently.


To get a value from a table/query, you have to open a
recordset. An easy way to retrive a single value is to use
the DLookup function which does that for you.

="record is added to " & DLookup("subphasename","qrytest")

That's probably not going to get what you want, but you
didn't explain enough for me to figure out what else you may
need to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top