Results 1 to 5 of 5
  1. #1
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    284

    Help using DSUM with Textboxes

    Greetings Experts ~

    I am having difficulty getting a second textbox to display the correct total of hours based on a date entered into a first textbox.

    Setup:

    Table Name: TestTable1
    Fields: 'RequestDate' & 'Hours'
    Form: 'Form1'
    2 Textboxes Unbound: Named 'Date' & 'Total'


    What I am trying to accomplish:

    Based upon a date entered into the "Date" textbox I want the "Total" textbox to display the total hours associated with that date.


    What I have tried:

    I have tried using, in the control source property of the "Total" textbox, many iterations of both Sum(IIF & DSum(

    I am currently using the following:

    =DSum("[Hours]","TestTable1","[RequestDate]='Forms! Form1!'Me.Date'")

    I have tried this without the Forms designation; without the "Me" designation; Etc.


    Some attempts return the Error or Name error while other efforts return a blank textbox

    As always, any help is greatly appreciated

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    284
    Quote Originally Posted by pbaldy View Post

    pbaldy - Thanks for chiming in ~

    Since I am trying to extract a numerical value I changed what I had to:

    =DSum("[PTOHours]","TestTable1","[RequestDate]= " & Forms! Form1! Date)

    However, when I click 'OK' Access changes it to the following

    =DSum("[PTOHours]","TestTable1","[RequestDate]= " & [Forms]![Form1]![Date])

    And while it doesn't give me an error - it also doesn't give me any value at all.


    I did try the following:

    =DSum("[PTOHours]","TestTable1","[RequestDate]= Date")

    And it would return the correct value, however, it would only return the correct value if I went from design view to form view.
    Once in form view I could enter a new date and nothing would happen, but if I went to design view then back to form view the correct total for the new date would appear.

    Getting closer but still need help

    Thanks in advance ~

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Date parameters need # delimiter.

    =DSum("[PTOHours]","TestTable1","[RequestDate]= #" & [Forms]![Form1]![Date] & "#")


    Date is a reserved word. Should not use reserved words as names. A better convention for naming controls is something like: tbxDate, cbxCustomer, etc.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    284
    Quote Originally Posted by June7 View Post
    Date parameters need # delimiter.

    =DSum("[PTOHours]","TestTable1","[RequestDate]= #" & [Forms]![Form1]![Date] & "#")


    Date is a reserved word. Should not use reserved words as names. A better convention for naming controls is something like: tbxDate, cbxCustomer, etc.

    pblady & June7 ~ Thank You both very much for your assistance. Naturally, June7, your suggestion worked perfectly. Paul, I realize now the link you posted in your reply also contained the correct answer but I was looking at the problem the wrong way. Instead of realizing I was working with a date parameter, I thought since I was trying to extract a numerical value I should use the example for numerical value. June7 I have since changed my textbox 'Date' to: 'TxtDate' - Thank You both very much for your help. This case is solved. Now, onto the next lesson.

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

Similar Threads

  1. Validate textboxes before more VBA
    By cjriebe in forum Programming
    Replies: 3
    Last Post: 06-25-2014, 09:07 AM
  2. Reports and Textboxes
    By jmenz in forum Reports
    Replies: 1
    Last Post: 03-25-2012, 08:38 PM
  3. Problem with sum of three textboxes.
    By SFC in forum Reports
    Replies: 3
    Last Post: 02-01-2012, 10:10 AM
  4. Formating Textboxes
    By desibabu90 in forum Forms
    Replies: 6
    Last Post: 08-02-2011, 07:48 AM
  5. #Name? errors with textboxes
    By jasonbarnes in forum Forms
    Replies: 3
    Last Post: 12-16-2010, 09:51 AM

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