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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using SQL for TextBox ControlSource

Status
Not open for further replies.

laijim

Programmer
Oct 4, 2010
6
US
I have a form with a text box where the textbox value should be populated with the maximum flowrate from a table. I wrote the following code:

txtTest.ControlSource = "SELECT DISTINCT MAX(FlowData_BoweryBay.[Flowrate]) FROM FlowData_BoweryBay;"

When I open the form, the textbox contains #Name?

What am I doing wrong?

Jim
 
use DMAX function:

txtTest.ControlSource = DMAX("Flowrate","FlowData_BoweryBay")

 
Thank you. Alas, I am getting the same #Name? error.

I am using Access 2007, does that make a difference?
 
What about this ?
txtTest.Value = DMAX("Flowrate","FlowData_BoweryBay")

or this ?
txtTest.ControlSource = "=DMAX(""Flowrate"",""FlowData_BoweryBay"")"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you, PHV!

Both approaches you suggested worked.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top