Results 1 to 3 of 3

Is this a bug in WorksheetFunction.Dsum ?

Threaded View

  1. #3
    Registered User
    Join Date
    03-09-2013
    Location
    Ottawa,Canada
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Is this a bug in WorksheetFunction.Dsum ?

    I solved my problem with WorkFunction.DSum by carefully matching the format of a date field with the target database using the excel Text function.

    The problem was obfuscated by the fact that the excel DSUM function seemed to work on examples of criteria blocks where DSum failed. And of course DSum did work on some examples.

    I developed the test harness test_dsum to methodically explore some simplified test data. The ability to organize and record results soon led to the solution.

    The description from test_dsum documents the testing ;

    '   FILENAME
    '   Test_dsum.xls
    '
    '   DATE
    '   07-Mar-13   Developed
    '
    '   DESCRIPTION
    '   A test harness to compare the results of Excel's DSUM function with WorksheetFunction.DSum
    '   The development was instigated by  noticing surprise results from an application using DSum
    '   The situation was made more confusing by the fact that DSUM seemed to be working on the same
    '   criteria block where DSum was failing. An organized way to run and record tests was needed
    '   and it quickly led to the situation being resolved. The following tests are shown here ;
    '       Test1   The criteria block contains conditions on a date field, DSUM works, DSum fails
    '       Test2   The date field is chosen with the format dd=mm, DSUM works, DSum works
    '       Test3   Only non-date fields are used in the criteria block, DSUM works, DSum works
    '       Test4   Rerun Test1 using the function Text to format date field, DSUM works,DSum works
    '               with generated criteria (left) but still fails with keyboard entered (right)
    '   Conclusion: When handling date fields in a DSum criteria block, the format must be carefully
    '   chosen to match the database fields using the excel Text function
    '
    '   NOTES ON THE CODE
    '   1. Each test generates its own worksheet, which contains a test description, timestamp
    '      and the results matrix
    '   2. A test may be rerun indefinitely. The timestamp will change and optionally the description
    '   3. The colour in the results matrix gives a quick automatic confirmation of the results
    '   4. The test name is automatically chosen by the software
    '   5. There is no limit on the number of tests. Adding a new test is easy. Supply a description and
    '      add a new Case branch where indicated. You will be notified if you forget.
    '   6. All the code is contained in Module1 and the code page of UserForm1
    '   7. Runs without change on Excel 2003 and Excel 2010 under Windows 7 and XP
    '   8. This test harness could be easily adapted to handle many other test scanarios
    '
    '   AUTHOR
    '   Desmond Walsh, Ottawa, Canada
    '
    '   ACKNOWLEDGEMENTS
    '   Some of the code was taken from samples provided in ;
    '       Excel 2007 Power Programming with VBA   John Walkenbach
    '   An excellent reference !
    I am attaching the test_dsum source code because I think it does a good job of managing simple testing, and it could be adapted to other test problems
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1