Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2008
    Posts
    18

    Unanswered: Steps to create a UDF?

    [Using Access 2003 with XP Pro]

    I have a need to calculate lead-times in business days rather than calender days. I've been fiddling around with the DateDiff() function, but it can't do business days. I think I found the best solution creating a UDF for a Microsoft-recommended DateDiffW() function.

    I've done some VBA work in Excel before, but Access is a whole new game to me. Regardless, I have the code and now just need the steps to create the UDF. I think I have some of the steps, but not all of them...

    Database view
    Modules - New
    Insert - ?Procedure?
    and I got nothing from that point on...

    Please help me identify the correct steps, as I need to be able to have this UDF for another query design.

    Any assistance will be greatly appreciated!

    Malvaro

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    You've done the hard bit. Paste in a new module. Scope should be Public not Private (Public is the default).

    Use:
    Code:
     SELECT fMyFunc([inputColumn]) AS func_output 
    FROM myTable
    This won't handle public holidays - you realise that right?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Nov 2008
    Posts
    18
    Quote Originally Posted by pootle flump
    You've done the hard bit. Paste in a new module. Scope should be Public not Private (Public is the default).

    Use:
    Code:
     SELECT fMyFunc([inputColumn]) AS func_output 
    FROM myTable
    This won't handle public holidays - you realise that right?
    Yah, I have been reading about how the work-around requires a seperate table identifying the dates of company-honored holidays...

    I just wish there was some built-in function like NETWORKDAYS in Excel...

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Personally I would do the lot in a table - it will be much more efficient. Try googling "calendar table database", "calendar table sql" etc.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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