Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2005

    Unanswered: can I assign a SQL statement to a text box on a form?

    Hello I am trying to create a sql statement that I can apply to an unbound text box on a form where it will take the value of the employee field and sum up the total amounts from one table for that employee.

    Here is what I am wanting. I have Employee John's record pulled up in a form which is based on the employee table

    now i have an unbound text box that averages the sales amounts he has made. which are on the sales table and there is a join between the employee numbers on each table.

    how would I apply this to the unbound text box?

    I tried putting in the control source for the unbound field on my Employee form:

    SELECT Sum(EmployeeSales.SaleTotal) AS SumOfSalesTotal FROM EmployeeSales Where EmployeeSales.EmployeeID = Employee.Employee_ID

    So this should sum up the SalesTotal for the employee that is pulled up on the Employee Form. but what shows up in the Unbound text box is #Name?

    Anyone have any suggestions?

    Thanks in advance.


  2. #2
    Join Date
    May 2005
    Nevada, USA
    Provided Answers: 6
    You can't have an SQL statement as the control source of a textbox. Try a DSum() instead.

  3. #3
    Join Date
    Sep 2003
    You could put the SQL statement as the record source (but then it would be bound ) ... Sounds like you need to populate your unbound textbox thru VBA ...
    Back to Access ... ADO is not the way to go for speed ...

  4. #4
    Join Date
    Dec 2006
    Yeah, it seems like it would belong in the OnCurrent event for the form itself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts