Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2004
    Posts
    10

    Post Unanswered: DSum'ing on a Date/Time Field Criteria

    How do I do a dsum calculation based upon a date field?

    Using
    Code:
    =DSum("totalsales","tips"," [emname] ='" & [Employee Name] & "'")
    where emname and Employee Name are text fields works wonderfully.

    How about if I replace those with transdate and transdate respectively but it is a date/time field?

    I kind of understand the concept of enclosing date/time in #'s but from what I've seen I couldn't find where it applies to matching it to a certain field.


  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,418
    Provided Answers: 7
    try

    =DSum("totalsales","tips"," [transdate] =#" & [Thisdate] & "#")

    But remeber USA format mm/dd/yyyy
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  3. #3
    Join Date
    Jun 2004
    Posts
    10

    Smile

    Got it!

    Code:
    =DSum("totalsales","tips"," [transdate] = #" & [transdate] & "#")

  4. #4
    Join Date
    Jun 2004
    Posts
    10

    Angry

    Maybe because it's late here but I'm stuck on another (probably) simple issue.

    I have a combo box set up to pull an person's name from a table and then place it in another. Works fine.

    How do I get corresponding text boxes to show data based upon the persons name that is selected?

    For example, you select Smith from the combo box and the box next to it should automatically show his file number.

  5. #5
    Join Date
    Jun 2004
    Posts
    96
    Assuming you already have a onclick event on combo box to show the name in another textbox right? You just need to perform Dlookup in order to return the value of another field basing on the search criteria you provided..

    example: textbox1 will reflect the search result from field: File Number, in TableName, searching the Name field for the value matching in Combo box

    Private Sub Combo_onClick()
    Me.textbox1 = DLookup("[File Number]", "TableName", "[Name] = '" & me.Combo & "'")

    End Sub

    Hope this helps..

    Cyherus

  6. #6
    Join Date
    Jun 2004
    Posts
    10
    Actually the combo box doesn't have anything assigned for it's event(s).

    I just choose the name and it's there

    This is what I have so far...
    Code:
    DLookup("[servernumber]", "employees", "[servernumber] = '" & me.employee name & "'")
    Where servernumber is the name of the field in the table that I want to get my data from as well as the name of the field on the form and employee name is the name of the combo box on the form.

    I'm off to bed before I make a critical mistake (like delete the whole dang thing!) I'll check back in the morning.

  7. #7
    Join Date
    Jun 2004
    Posts
    96
    that's what I mean.
    you have to have events assigned to the combo box, in order to trigger the program to perform the task of 'dlookup'..

    Cyherus

Posting Permissions

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