Stupid Question... Sql and a text box...
Ok, I have a report in access that I am adding a text field to.
I have a select statement that returns one value.
I want that select statement to put the value into the text box.
I have been going crazy today figuring it out. All I get is #NAME?
Here is what the source is.
= (Select Top 1 NumAdj From TblName) Thats all. Once I get that to return something, Then I can add a where clause.
Thanks.
Re: Stupid Question... Sql and a text box...
Quote:
= (Select Top 1 NumAdj From TblName)
is not proper VBA syntax fror a textbox ControlSource.
Try
="Select Top 1 NumAdj From TblName"
Alternatively, TblName is mispelled, or "NumAdj" is not a field in "TblName."
Re: Stupid Question... Sql and a text box...
I guess this is more of an Access question than a VBA question. I am trying to get the sql statement in using the front in. (Properties Window) Anyone know if that is possible.
Quote:
Originally Posted by llkhoutx
is not proper VBA syntax fror a textbox ControlSource.
Try
="Select Top 1 NumAdj From TblName"
Alternatively, TblName is mispelled, or "NumAdj" is not a field in "TblName."
Re: Stupid Question... Sql and a text box...
Quote:
Originally Posted by wookie224
I guess this is more of an Access question than a VBA question. I am trying to get the sql statement in using the front in. (Properties Window) Anyone know if that is possible.
What does that mean? You could create the query in the query section of the database and set the control source to that.
Re: Stupid Question... Sql and a text box...
For a report, you can only have one recordsource. From that recordsource
you can map textboxes to the rs' fields. You can not execute a select
statement on a report.
Is seems like you can do one of two things:
- Modify your reports reportsource to include the field you need by modifing
the query. - Add a sub-report with the sql statement as its recordsource and the
subform will have the textbox mapped to the field you need.
HTH