Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    OCStan is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    15

    I added the function to a module. How do I run the function?

  2. #17
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It will be used in your Update query. Something like:
    Set OldDateField = BumpDate(OldDateField, 1)

  3. #18
    OCStan is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    15
    Sorry but I'm not sure where to add this in the update query.

  4. #19
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Post the SQL for your Update query.

  5. #20
    OCStan is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    15
    Here is the SQL for the update query.

    UPDATE [Job Info] INNER JOIN STRUCTURES ON [Job Info].[Order Number] = STRUCTURES.[ORDER NUMBER] SET STRUCTURES.SCHEDULED = DateAdd("d",1,[scheduled])
    WHERE (((STRUCTURES.SCHEDULED) Is Null) AND ((STRUCTURES.PRIORITY)>0)) OR (((STRUCTURES.SCHEDULED)>=Date()));

  6. #21
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Change this: SET STRUCTURES.SCHEDULED = DateAdd("d",1,[scheduled])
    ...to... : SET STRUCTURES.SCHEDULED = BumpDate(scheduled, 1)

  7. #22
    OCStan is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    15
    That works great, thank you. Is it possible to add holidays as skip days?

  8. #23
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Yes, but I have to leave for several hours so you'll have to wait for my help on this. Sorry.

  9. #24
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Replace the existing Function with this code. Assuming a tblHolidays, this should skip those as well.
    Code:
    Function BumpDate(InDate As Date, BumpBy As Integer) As Date
    ' Adjust the InDate by the BumpBy value, skipping weekends and Holidays
    ' If you want to bump by one then use:
    ' NewDate = BumpDate(OldDate, 1)
       On Error GoTo Err_BumpDate
       Dim rst As DAO.Recordset
       Dim dbs As DAO.Database
       Dim Looping As Boolean
       On Error GoTo ErrHandler
       Set dbs = CurrentDb
       Set rst = dbs.OpenRecordset("tblHolidays", dbOpenSnapshot)
       Looping = True
       BumpDate = InDate
       Do While Looping
          BumpDate = BumpDate + BumpBy
          If Weekday(BumpDate, vbMonday) < 6 Then
             ' This is a weekday. Check for a Holiday
             rst.FindFirst "[HolidayDate] = #" & Format(BumpDate, "mm\/dd\/yyyy") & "#"
             If rst.NoMatch Then
                Looping = Weekday(BumpDate, vbMonday) > 5
             End If
          End If
       Loop
    Exit_BumpDate:
       On Error Resume Next
       rst.Close
       Set rst = Nothing
       Set dbs = Nothing
       Exit Function
    Err_BumpDate:
       MsgBox "Error No:    " & lngErrNumber & vbCrLf & _
              "Description: " & strErrDescription
       Resume Exit_BumpDate
    End Function

  10. #25
    OCStan is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    15
    Thank you. This has been very helpful.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. production records
    By adriana in forum SQL Server
    Replies: 3
    Last Post: 05-11-2013, 11:16 AM
  2. Pushing Data From one form to another
    By zipmaster07 in forum Forms
    Replies: 21
    Last Post: 02-03-2012, 10:30 AM
  3. Replies: 0
    Last Post: 12-07-2011, 09:37 AM
  4. Production Tracking
    By old_chopper in forum Access
    Replies: 2
    Last Post: 10-11-2010, 12:12 PM
  5. Production
    By teranet in forum Access
    Replies: 1
    Last Post: 06-07-2008, 06:47 AM

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