Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Work Days    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Undefined Function message
Nancy Ramirez 
    
2 years ago
Hello,

I used the below code, to run workdays query, but I continue to get the message that MyNetWorkDays is Undefined Function. Maybe someone can spot where I got the code wrong.

Thank you,

Public Function MyNetWorkDays(StartDate as Date, EndDate As Date) As Long

    Dim D As Date, OKToAdd as Boolean, H as Long

    MyNetWorkDays = 0
    D = StartDate
    While D <= EndDate
    OKToAdd = False


'Mon thru Friday
        If Weekday(D) > 1 And Weekday(D) < 7 Then OKToAdd = True

'Static Holiday'
If Month (D) = 1 And Day (D) =1 then OKToAdd = False 'New Years Day'
If Month (D) = 6 And Day (D) =19 then OKToAdd = False 'Juneteenth'
If Month (D) = 7 And Day (D) =4 then OKToAdd = False 'Independence'
If Month (D) = 11 And Day (D) =11 then OKToAdd = False 'Veterans'
If Month (D) = 12 And Day (D) =25 then OKToAdd = False 'Christmas'


If OKToAdd Then MyNetworkDays = MyNetworkDays + 1

        D = D + 1

Wend

' Holidays in Table
H = Nz (DCount("*","tblHolidays","HolidayDate Between #" & StartDate & _
"# AND #" & EndDate & "#"), 0)
MyNetworkDays =  MyNetworkDays - H

End Function
Richard Rost  @Reply  
          
2 years ago
Where did you put this function? Is it in a global module or in a form module? In order for you to use a query, it has to be in a Global module.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Work Days.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/30/2026 6:53:28 AM. PLT: 1s