Results 1 to 15 of 15
  1. #1
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451

    newbie question.

    i'm trying to work on a vacation scheduler for employees to input vacation dates. I have a table for dates and a table for holidays and am trying to use the module from https://msdn.microsoft.com/en-us/lib...ffice.12).aspx. I've copied the code from the calculating working days and am getting an error undefined function 'workdays' in expression. i'm sorry but i'm just starting with modules and i'm lost. any help would be appreciated.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You would have needed to copy that function into a standard module (not behind a form/report), and make sure the module doesn't have the same name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    it names itself? here's my expression in the query that is getting the error. Expr1: Sum(workdays([startdate],[enddate])). this is a common module so i'm sure it works, I've just never done one before and i'm sure i'm missing something. I copied the code into a blank module and saved it. then tried using it in a query. no luck. please help me understand.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What did you name the module when you saved it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    I saved it as workdays

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Did you miss

    Quote Originally Posted by pbaldy View Post
    and make sure the module doesn't have the same name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    not sure where you are getting that, I did exactly like the page said.To create the user-defined functions

    1. Click the Microsoft Office Button, click Open, and then open the database where you want to insert the functions.
    2. On the Microsoft Office Fluent Ribbon, click Database Tools.
    3. On the Macro tab, click Visual Basic.
    4. On the Insert menu, click Module.
    5. At the top of the module, type the following two lines, if they are not already there.
      Option Compare Database
      Option Explicit
    6. Type the Workdays and Weekdays functions exactly as you see them in the previous code example. Or, if you downloaded the sample database, copy and paste the functions from the Business Date Calculations module.
    7. On the File menu, click Save.
    8. Type a module name, such as Working Days, and then press ENTER.
    9. On the Debug menu, click Compile.
    10. On the File menu, click Close and Return to Microsoft Office Access.


    After you place the functions in your database, you can use them in Access objects such as queries, forms, and reports.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    ..........
    Quote Originally Posted by vicsaccess View Post
    I saved it as workdays

    Quote Originally Posted by vicsaccess View Post
    1. Type a module name, such as Working Days, and then press ENTER.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Don't know how else to say it. The module can not have the same name as the function.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    I've tried multiple names. I give up

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can post the db here if you want.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    Vacation1.ziphere's the DB. the module is workingdays and i'm trying to use it in query TimeQ. I really want to learn more but i'm getting frustrated. any help helping me get this working and learning my errors would greatly be appreciated.

  13. #13
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    sorry, when I was trying to get the personal information and extra tables deleted to make the file size small enough it looks like I deleted my holiday table. i'm trying to use the module to take the employee from the employeeT and the vacation entries from TimeT and get working days minus holidays that are listed in the tblholidays. I know this is not that hard but its my first attempt and i'm failing. someone please tell me what i'm doing wrong.

    Vacation2.zip

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The second sample is still missing a query, but the primary problem is the same. You've named the module "WorkingDays", and you've named the function "WorkingDays". THEY CAN'T BE THE SAME. Change the name of the function to "WorkDays" and try again.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #15
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    Thank you all

Please reply to this thread with any new information or opinions.

Similar Threads

  1. newbie question
    By sbrady19 in forum Access
    Replies: 4
    Last Post: 02-10-2015, 01:25 PM
  2. Hi and a newbie question :)
    By wheelspin in forum Queries
    Replies: 3
    Last Post: 11-28-2011, 01:11 PM
  3. Newbie question please help
    By Napier in forum Access
    Replies: 1
    Last Post: 11-28-2011, 09:00 AM
  4. Question from a newbie
    By scarps626 in forum Access
    Replies: 2
    Last Post: 10-02-2009, 03:40 AM
  5. Newbie question
    By The_Dude in forum Programming
    Replies: 2
    Last Post: 12-23-2007, 07:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums