Results 1 to 2 of 2
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    Dsum problem when filtering by dates and with machine names

    Hi guys



    I am having a really hard time with a dsum.

    the code below runs on a forms onload event

    Private Sub Form_Load()

    'code below is for the KDM areas
    Me.KDMTXTBox = DCount("CriticalChangeMachineID", "SignificantEventLogMachine", "CriticatMachineLocation = 2") '2=KDM from theSignificantMachineLogLocationTable
    Me.KDMDailyCapacityTXTbox = DLookup("DailyCapacity", "UNEXcapacity", "'MachineArea=kdm'")
    Me.KDMDaysWorkedTXTbox = DLookup("DaysWorked", "UNEXcapacity", "'MachineArea=kdm'")

    Dim AverageCapacity As String
    AverageCapacity = Round(Me.KDMDailyCapacityTXTbox / Me.KDMDaysWorkedTXTbox / Me.KDMTXTBox, 2)
    KDMAverageCapacityTXTbox = AverageCapacity

    Dim CapacityDatesQuery As String
    CapacityDatesQuery = "DueDate Between #" & [Forms]![form1]![StartDate] & "# And #" & [Forms]![form1]![EndDate] & "#"
    Me.KDM1TXTbox = Me.KDMAverageCapacityTXTbox

    Me.KDM1ActualCapacityTXTBox = Nz(DSum("QTYOUTST", "UNEXProcess", CapacityDatesQuery And "Machine = 'KDM 1'"), 0)
    Me.Text36 = Nz(DSum("QTYOUTST", "UNEXProcess", "Machine='KDM 3'"), 0)
    Me.Text37 = Nz(DSum("QTYOUTST", "UNEXProcess", "Machine='KDM 4'"), 0)
    Me.Text38 = Nz(DSum("QTYOUTST", "UNEXProcess", "Machine='KDM 5'"), 0)
    Me.Text39 = Nz(DSum("QTYOUTST", "UNEXProcess", "Machine='KDM 6'"), 0)
    Me.Text40 = Nz(DSum("QTYOUTST", "UNEXProcess", "Machine='KDM 7'"), 0)
    Me.Text41 = Nz(DSum("QTYOUTST", "UNEXProcess", "Machine='KDM 8'"), 0)
    End Sub

    basically what I want this code to do is work out the capacity of our machines on the warehouse floor.

    this line is coursing me issues
    Me.KDM1ActualCapacityTXTBox = Nz(DSum("QTYOUTST", "UNEXProcess", CapacityDatesQuery And "Machine = 'KDM 1'"), 0)

    this line works using the code below
    Me.KDM1ActualCapacityTXTBox = Nz(DSum("QTYOUTST", "UNEXProcess", CapacityDatesQuery ),0)

    but what I really need to do is filter the result to show the total for the machine

    when I add the machine to the code I get an "Run time error '13': type mismatch" error

    the column "Machine" in the table "UNEXProcess" that the dsum is referencing has the machine name in text, so im pretty stumped as to what to do

    any help would be most welcome, I think I've got to the point were I cant see the woods for the trees.

    many thanks

    Steve

  2. #2
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi All

    I have managed to sort this

    I am now selecting dates from a form called UnexCapacityDatesSelectionForm

    I changed the code to this
    = Nz(Round(DSum("QTYOUTST", "UNEXProcess", "Completed = 0 And Machine = 'KDM 1' and dueDate Between #" & [Forms]![UnexCapacityDatesSelectionForm]![StartDate] & "# And #" & [Forms]![UnexCapacityDatesSelectionForm]![EndDate] & "#"), 2), 0)

    instead of declaring the dates I added them within the code and was even able to only sum the values for the completed jobs
    woop woop

    Steve

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

Similar Threads

  1. Dsum filtering
    By ICBSprod in forum Forms
    Replies: 2
    Last Post: 02-01-2014, 01:40 AM
  2. Replies: 2
    Last Post: 06-17-2013, 11:24 AM
  3. filter dsum between dates on a form
    By sdel_nevo in forum Forms
    Replies: 5
    Last Post: 06-03-2013, 03:07 PM
  4. DSum problem.
    By kowalski in forum Access
    Replies: 1
    Last Post: 10-26-2012, 05:24 PM
  5. Filtering on Field Names from Table
    By reddog1898 in forum Access
    Replies: 3
    Last Post: 05-13-2011, 10:47 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