Function "Workingdays" query error date

I am trying to calculate the number of days, excluding weekends, between two 
dates.  I am using the "workingdays" VBA code.  I have pasted the code in a 
module, naming it "mdlWorkingdays".  The code is listed below along with a 
sample of the data.
"mdlWorkingdays"
Option Compare Database

'*********** Code Start **************
Public Function Workingdays(Start_Date As Date, End_Date As Date) As Integer
'....................................................................
' Name:     WorkingDays
' Inputs:   StartDate As Date
'   EndDate As Date
' Returns: Integer
' Author: Arvin Meyer
' Date:     February 19, 1997
' Comment: Accepts two dates and returns the number of weekdays between them
' Note that this function does not account for holidays.
'....................................................................
On Error GoTo Err_WorkingDays

Dim intCount As Integer

Start_Date = Start_Date + 1
'If you want to count the day of Start_Date as the 1st day
'Comment out the line above

intCount = 0
Do While Start_Date <= End_Date
'Make the above < and not <= to not count the End_Date

Select Case Weekday(Start_Date)
Case Is = 1, 7
intCount = intCount
Case Is = 2, 3, 4, 5, 6
intCount = intCount + 1
End Select
Start_Date = Start_Date + 1
Loop
Workingdays = intCount

Exit_WorkingDays:
Exit Function

Err_WorkingDays:
Select Case Err

Case Else
MsgBox Err.Description
Resume Exit_WorkingDays
End Select

End Function

Sample Data:
Start_Date	  End_Date
2/14/2006	  2/20/2006
2/14/2006	  2/21/2006
2/15/2006	  2/15/2006
2/10/2006	  2/10/2006

I have been trying to use the function in a query.  Each time, I get the 
following error: "Ambiguous name. in query 
'Workingdays([Start_Date],[End_Date])'.
Any help in solving this problem would be greatly appreciated.
0
Utf
6/9/2007 2:47:01 AM
access.queries 6343 articles. 1 followers. Follow

4 Replies
1169 Views

Similar Articles

[PageSpeed] 14

On Fri, 8 Jun 2007 19:47:01 -0700, Steve <Steve@discussions.microsoft.com>
wrote:

>I have been trying to use the function in a query.  Each time, I get the 
>following error: "Ambiguous name. in query 
>'Workingdays([Start_Date],[End_Date])'.

Please post the SQL of the query. I don't think it's a problem with the
function itself; perhaps you're naming the calculated field from Workingdays
with a name that you have already used in the query.

             John W. Vinson [MVP]
0
John
6/9/2007 3:38:38 AM
Do a search of your database. Access is saying that you've got more than one 
function named Workingdays in your database.

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Steve" <Steve@discussions.microsoft.com> wrote in message 
news:FD4E36AE-27DA-44F6-8F45-CFAE60A01B6C@microsoft.com...
>I am trying to calculate the number of days, excluding weekends, between 
>two
> dates.  I am using the "workingdays" VBA code.  I have pasted the code in 
> a
> module, naming it "mdlWorkingdays".  The code is listed below along with a
> sample of the data.
> "mdlWorkingdays"

> I have been trying to use the function in a query.  Each time, I get the
> following error: "Ambiguous name. in query
> 'Workingdays([Start_Date],[End_Date])'.
> Any help in solving this problem would be greatly appreciated. 


0
Douglas
6/9/2007 10:49:52 AM
On Sat, 9 Jun 2007 06:49:52 -0400, "Douglas J. Steele"
<NOSPAM_djsteele@NOSPAM_canada.com> wrote:

>Do a search of your database. Access is saying that you've got more than one 
>function named Workingdays in your database.

Ahhh.... that's almost surely it, Douglas. Thanks for the catch!

             John W. Vinson [MVP]
0
John
6/9/2007 3:33:54 PM
Thank you for your help.  Problem solved. I didn't expect anyone to reply 
that quickly.  I really appreciate it.  

"John W. Vinson" wrote:

> On Sat, 9 Jun 2007 06:49:52 -0400, "Douglas J. Steele"
> <NOSPAM_djsteele@NOSPAM_canada.com> wrote:
> 
> >Do a search of your database. Access is saying that you've got more than one 
> >function named Workingdays in your database.
> 
> Ahhh.... that's almost surely it, Douglas. Thanks for the catch!
> 
>              John W. Vinson [MVP]
> 
0
Utf
6/11/2007 11:51:02 PM
Reply:

Similar Artilces:

Function "Workingdays" query error date
I am trying to calculate the number of days, excluding weekends, between two dates. I am using the "workingdays" VBA code. I have pasted the code in a module, naming it "mdlWorkingdays". The code is listed below along with a sample of the data. "mdlWorkingdays" Option Compare Database '*********** Code Start ************** Public Function Workingdays(Start_Date As Date, End_Date As Date) As Integer '.................................................................... ' Name: WorkingDays ' Inputs: StartDate As Date ' EndDate As Da...

networkingdays function
This is very useful but we would like to be able to vary which day is "a nn working day" ie not necessarily saturday or sunday. We used to be able to do this with Lotus 123, but have now migrated to excel. Is there any way of achieving this please? Hi! Myrna Larson posted this solution back in June last year: If you need to include holidays, as you can do with NETWORKDAYS, =NETWORKDAYS(A1+1,A2+1,HolidayRange) This just "tricks" Excel into thinking that a Friday is really a Saturday, a Saturday is a Sunday, and a Sunday is a Monday, so it excludes Fridays and Sa...