Is there any way populate an Access Form's text feild's value using SQL?
I have read that it is not possible to simply enter SQL as the Control Source. Is this true?
thanks for any halp :)
--edit--
I need to perform this query;
SELECT tblCaseIssues.IssueDesc FROM tblCaseIssues INNER JOIN tblCaseNewHS_Issues ON tblCaseIssues.ID = tblCaseNewHS_Issues.IssueID WHERE(tblCaseNewHS_Issues.HS_ID = 81))
I have created the following function to solve this very problem. I like this solution because you don't have to deal with saved queries clogging up your navigation pane or long workarounds.
This was the way I explained it to my boss. "You can have a DLookUp() function as a control source of a text box. Why not just write a function that does a query and use the function as the control source?" Give it a try, it fixed my situation.
It might be easiest to use a combobox and set the Row Source to your query, alternatively, DAO is native to Access.
Just take your sql query and save it as a query.
Then in the text box, just place:
=(dlookup(“IssuesDesc”,”name of query”))
I at a rather large loss as to all these posters suggesting whacks of code where as none is needed at all . Just save your sql as a query and then use the dlookup() function as the text box’s data source and you are done.
Pretty sure that is true SQL, but you could use the function:
=DLookUp("field_name","table_name","any_fieldname = 'value'")
You can set the control source of your field to a function name. That function can easily execute your SQL, and/or pass in a variable. Here's my simple boiler plate for a function to execute a SQL statement into a recordset and return the first value. In my world I'm usually including a very specific where clause, but you could certainly make any of this function more robust for your needs.