Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement in ControlSource Property 1

Status
Not open for further replies.

Jackie

MIS
Joined
Feb 9, 2000
Messages
148
Location
US
What is the correct syntax for using an SQL statement in the ControlSource property of a report text box?<br><br>I placed the following code in the ControlSource property of a text box located on a report:<br><br>=(SELECT tbl_Letter_Vars. Effective_Date FROM tbl_Letter_Vars)<br>When I run the report, the value is not printing. &quot;#Name?&quot; is displayed in the textbox field.<br><br>I have tried several variations in the syntax such as eliminating the =, using brackets around the table and field names, and including a ; at the end of the statement.<br><br>
 
While you can't use an actual SQL statement in the ControlSource property of a control (this property is usually used to select one of the fields from the Reports &quot;RecordSource&quot;), you can use the DLookUp function...<br><br>=DLookUp(&quot;fieldname&quot;,&quot;tablename&quot;,&quot;criteria&quot;)<br><br>=DLookUp(&quot;Effective_Date&quot;,&quot;tbl_Letter_Vars&quot;)<br><br>or to include a &quot;where&quot; clause...<br><br>=DLookUp(&quot;Effective_Date&quot;,&quot;tbl_Letter_Vars&quot;,&quot;MyField = 'A' &quot;) <br><br>&nbsp; <p>Jim Conrad<br><a href=mailto:jconrad3@visteon.com>jconrad3@visteon.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top