Results 1 to 2 of 2
  1. #1
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87

    Need to display calculation in field on a form

    I have create a query that gives me a total of the amount that will be billed (on either the 1st or 15th) of the month. This amount needs to populate into a text box on the form after the user selects the date they want to do the billing for (1 or 15). Concept is... tell me how much i will bill if I create the invoices today. So the steps are:

    User selects a billing date (either 1 or 15) from a combo on the form. I was running this code:
    Dim TtlBl As String
    Dim BillDt As Integer

    BillDt = Me.cboPrntInv



    'DoCmd.OpenQuery "qryGetBillTotals"

    'TtlBl = "SELECT tblCompanyExtras.DateBilled, CompanyInformation.CompanyBillingDate, " _
    '& "Sum(([ExtraCost]*[ExtrasQty])+[CompanyContractAmt]) AS ExtraTotal " _
    '& "FROM CompanyInformation LEFT JOIN tblCompanyExtras ON " _
    '& "CompanyInformation.CompanyAccountNo = tblCompanyExtras.CompanyId " _
    '& "GROUP BY tblCompanyExtras.DateBilled, CompanyInformation.CompanyBillingDate " _
    '& "((CompanyInformation.CompanyBillingDate)= " & BillDt & "));"


    Me.txtTotBld.RowSource = TtlBl

    But the field was not updating. I tried setting the recordsource or control source to both the query and the select statement but I'm still not getting the total to display in the field.

    Here is the query:
    SELECT Sum(([ExtraCost]*[ExtrasQty])+[CompanyContractAmt]) AS ExtraTotal
    FROM CompanyInformation LEFT JOIN tblCompanyExtras ON CompanyInformation.CompanyAccountNo = tblCompanyExtras.CompanyId
    WHERE (((tblCompanyExtras.DateBilled) Is Null) AND ((CompanyInformation.CompanyBillingDate)=[Forms]![frmCreateInvoices]![cboPrntInv]));

    Thanks, Tina

  2. #2
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    Quote Originally Posted by TinaCa View Post
    I have create a query that gives me a total of the amount that will be billed (on either the 1st or 15th) of the month. This amount needs to populate into a text box on the form after the user selects the date they want to do the billing for (1 or 15). Concept is... tell me how much i will bill if I create the invoices today. So the steps are:

    User selects a billing date (either 1 or 15) from a combo on the form. I was running this code:
    Dim TtlBl As String
    Dim BillDt As Integer

    BillDt = Me.cboPrntInv

    'DoCmd.OpenQuery "qryGetBillTotals"

    'TtlBl = "SELECT tblCompanyExtras.DateBilled, CompanyInformation.CompanyBillingDate, " _
    '& "Sum(([ExtraCost]*[ExtrasQty])+[CompanyContractAmt]) AS ExtraTotal " _
    '& "FROM CompanyInformation LEFT JOIN tblCompanyExtras ON " _
    '& "CompanyInformation.CompanyAccountNo = tblCompanyExtras.CompanyId " _
    '& "GROUP BY tblCompanyExtras.DateBilled, CompanyInformation.CompanyBillingDate " _
    '& "((CompanyInformation.CompanyBillingDate)= " & BillDt & "));"


    Me.txtTotBld.RowSource = TtlBl

    But the field was not updating. I tried setting the recordsource or control source to both the query and the select statement but I'm still not getting the total to display in the field.

    Here is the query:
    SELECT Sum(([ExtraCost]*[ExtrasQty])+[CompanyContractAmt]) AS ExtraTotal
    FROM CompanyInformation LEFT JOIN tblCompanyExtras ON CompanyInformation.CompanyAccountNo = tblCompanyExtras.CompanyId
    WHERE (((tblCompanyExtras.DateBilled) Is Null) AND ((CompanyInformation.CompanyBillingDate)=[Forms]![frmCreateInvoices]![cboPrntInv]));

    Thanks, Tina
    I made it too complicated. Instead of above, I created a query for the ControlSource (based on the code above) of the field and after a user clicks the combo I added a Refresh to the Afterupdate event.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Display Query field in form?
    By Ray67 in forum Queries
    Replies: 17
    Last Post: 06-01-2012, 12:44 PM
  2. Replies: 3
    Last Post: 01-17-2012, 01:04 PM
  3. Replies: 5
    Last Post: 08-11-2011, 05:38 PM
  4. Display Web Page in a MS Access Form/Field
    By webinteractive in forum Forms
    Replies: 3
    Last Post: 04-01-2011, 03:53 PM
  5. Calculation field in form
    By ste_pie87 in forum Access
    Replies: 1
    Last Post: 03-24-2009, 08:28 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums