Re: Using a module in a query

From: Ted Allen (anonymous_at_discussions.microsoft.com)
Date: 06/02/04


Date: Wed, 2 Jun 2004 07:17:55 -0700

My pleasure, glad it helped.

>-----Original Message-----
>Ted-
>
>Thanks so much. I was using the name that I saved the
module as
>instead of the name of the function! Typed in what you
said and it
>worked perfectly. I appreciate the help and the
detailed explanation!
>
>Cheers!
>Chris
>
>
>"Ted Allen" <anonymous@discussions.microsoft.com> wrote
in message news:<16b3101c44827$a14e6390
$a301280a@phx.gbl>...
>> Hi Chris,
>>
>> Assuming that you have already pasted the function
into a
>> module and saved it (if not you must do this first),
all
>> you have to do to use the function is reference it
like
>> any built in function.
>>
>> So, if you have a query with fields titled StartDate
and
>> EndDate (the date fields could have any name), you
just
>> enter the following expression in a blank column in
your
>> query builder:
>>
>> Work_Days([StartDate],[EndDate])
>>
>> Note that the []'s are really only needed if the field
>> names have spaces.
>>
>> If you want to give the column a meaningful name, you
can
>> enter it before the expression followed by a colon,
such
>> as:
>>
>> Working Days: Work_Days([StartDate],[EndDate])
>>
>> One final note, any custom functions that have been
saved
>> in modules in your database are visible using the
>> builder. To see this, go to a field in a blank column
>> and right-click then choose "Build...". When the
builder
>> opens, choose functions and then you will see a
listing
>> for built in functions and also a listing with your
>> database name. If you double-click your database name
>> you will see your modules, and if you click on any of
>> them you will see the custom functions they contain.
>> Double-Clicking a custom function will insert it into
>> your field expression, with the variable names as
>> placeholders. But, you then substitute your field
names
>> for the variable names.
>>
>> HTH, Ted Allen
>> >-----Original Message-----
>> >I am trying to call the following module (which I
>> borrowed from "The
>> >Access Web") to calculate the number of business
days.
>> Here is the
>> >module:
>> >
>> >Function Work_Days(BegDate, EndDate) As Integer
>> >' Note that this function does not account for
holidays.
>> >Dim WholeWeeks As Variant
>> >Dim DateCnt As Variant
>> >Dim EndDays As Integer
>> >
>> > BegDate = DateValue(BegDate)
>> >
>> > EndDate = DateValue(EndDate)
>> > WholeWeeks = DateDiff("w", BegDate, EndDate)
>> > DateCnt = DateAdd("ww", WholeWeeks, BegDate)
>> > EndDays = 0
>> > Do While DateCnt < EndDate
>> > If Format(DateCnt, "ddd") <> "Sun" And _
>> > Format(DateCnt, "ddd")
>> <> "Sat" Then
>> > EndDays = EndDays + 1
>> > End If
>> > DateCnt = DateAdd("d", 1, DateCnt)
>> > Loop
>> > Work_Days = WholeWeeks * 5 + EndDays
>> >End Function
>> >'*********** Code End **************
>> >
>> >I have a query that has BegDate and EndDate and I
want
>> to add a new
>> >column that will call this module and give me the
number
>> of business
>> >days. The problem is this...I have never called a
>> module before!!
>> >Can someone please provide me with a detailed
>> explanation of exactly
>> >what needs to be written to get this to work???
>> >
>> >Thanks so much!
>> >
>> >Chris (Newbie)
>> >.
>> >
>.
>



Relevant Pages

  • Re: A Call to Arms from Richard VanGrunsven
    ... I'd tend to say that an airplane built by Joe Blow ... Pro Built is very easy to define. ... else's plane, he becomes a professional builder. ...
    (rec.aviation.homebuilt)
  • Re: Buying/selling homebuilts
    ... homebuilt aircraft is that it is an experimental plane, ... pleasure/education of the builder. ... The builder of said plane, ... Remember - each individual homebuilt aircraft is unique. ...
    (rec.aviation.homebuilt)
  • Re: How do you know if your contractor is doing a good job?
    ... "My wife and I are getting ready to have a house built, ... wondering how I can objectivley tell if the builder is doing things ... lot of control in the first situation and put it into the contract. ... required local inspections. ...
    (misc.consumers.house)
  • Re: "too much trouble to go to the polls", WTF!? (was Re: Compulsory
    ... Then the builder ... > Is fucking off the same as dropping dead? ... in was presumably also built where there once were trees. ...
    (rec.arts.sf.fandom)
  • Re: printing format
    ... How about copying that range into MSWord and using Word's built in features. ... pick up your listing and toss the word file--it's out of date as ...
    (microsoft.public.excel.misc)