Page 2 of 2 FirstFirst 12
Results 16 to 27 of 27
  1. #16
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Not sure I understand what you are wanting. If you want to change the due date to Monday if the due date is a Fri, Sat or Sun, you could use the WeekDay() function to determine if the current due date is a Fri, Sat or Sun and add a number of days to get the following Monday.



    The Weekday function can return any of these values:
    Constant Value Description
    vbSunday 1 Sunday
    vbMonday 2 Monday
    vbTuesday 3 Tuesday
    vbWednesday 4 Wednesday
    vbThursday 5 Thursday
    vbFriday 6 Friday
    vbSaturday 7 Saturday


    Example:
    Due Date = Sep 13 2018. (Sep 13 2018 is a Thur.)
    Function WeekDay(Sep 13 2018) returns 5, therefore NOT Fri, Sat or Sun.

    Due Date = Sep 14 2018. (Sep 14 2018 is a Fri.)
    Function WeekDay(Sep 14 2018) returns 6, therefore IS a Fri.


    If the Function WeekDay() returns a 6, 7 or 1 (Fri, Sat or Sun), then add days to Due Date
    This is an example of code to change the due date:
    Code:
        Dim DOW As Integer
        DOW = WeekDay(DueDate)
    
        Select Case DOW
              Case 1      'Sun
                     DueDate = DateAdd("d", 1, DueDate)
              Case 6      'Fri
                     DueDate = DateAdd("d", 3, DueDate)
              Case 7      'Sat
                     DueDate = DateAdd("d", 2, DueDate)
              Case Else      'all other days
                     'do nothing
    End Select

  2. #17
    markpastoril is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    62
    thanks for the quick response sir,but where would I put this code?coz my due date was nested in a query.

  3. #18
    JSR is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2018
    Location
    Reno, NV
    Posts
    41
    Create a user-defined function (in a module)

    Code:
    public function GetNewDueDate(DueDate as date) as date
    
    Dim DOW As Integer
        
    DOW = WeekDay(DueDate)
    
    Select Case DOW
      Case 1      'Sun
       GetNewDueDate = DateAdd("d", 1, DueDate)
      Case 6      'Fri
       GetNewDueDate = DateAdd("d", 3, DueDate)
      Case 7      'Sat
       GetNewDueDate = DateAdd("d", 2, DueDate)
      Case Else   'all other days, do nothing
       GetNewDueDate = DueDate
    End Select
    
    end function
    then just refer to GetNewDueDate([DueDate]) in your query

  4. #19
    markpastoril is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    62
    tried each code sir, but didn't work for me.

  5. #20
    markpastoril is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    62
    Quote Originally Posted by JSR View Post
    Create a user-defined function (in a module)

    Code:
    public function GetNewDueDate(DueDate as date) as date
    
    Dim DOW As Integer
        
    DOW = WeekDay(DueDate)
    
    Select Case DOW
      Case 1      'Sun
       GetNewDueDate = DateAdd("d", 1, DueDate)
      Case 6      'Fri
       GetNewDueDate = DateAdd("d", 3, DueDate)
      Case 7      'Sat
       GetNewDueDate = DateAdd("d", 2, DueDate)
      Case Else   'all other days, do nothing
       GetNewDueDate = DueDate
    End Select
    
    end function
    then just refer to GetNewDueDate([DueDate]) in your query
    Tried this code, and the other column did change but why are the other column did not change?pls help me through this
    Click image for larger version. 

Name:	code.jpg 
Views:	20 
Size:	128.9 KB 
ID:	35723Click image for larger version. 

Name:	data.jpg 
Views:	20 
Size:	73.2 KB 
ID:	35724Click image for larger version. 

Name:	design view.jpg 
Views:	20 
Size:	101.7 KB 
ID:	35725

  6. #21
    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 aren't setting a return value for GetNewDueDate when the Else clause is met (like JSR did).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #22
    markpastoril is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    62
    Wooah that's what i've missed sir.and it work now thanks a lot sir

  8. #23
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem, JSR did the heavy lifting.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #24
    markpastoril is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    62
    Yeah right thanks @JSR

  10. #25
    markpastoril is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    62
    I want to set up a senior citizens discount table sir with the details in it,and connected to customers table.how to do it properly?

  11. #26
    markpastoril is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    62
    Thanks @ssanfu

  12. #27
    markpastoril is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    62
    this it the relationship I"ve set up,is this the proper/correct way?Click image for larger version. 

Name:	sc discount.jpg 
Views:	11 
Size:	79.5 KB 
ID:	35750

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

Similar Threads

  1. Replies: 6
    Last Post: 11-10-2017, 05:00 PM
  2. Getting a non-automatic ID to become AUTOMATIC !
    By THE STUDENT in forum Access
    Replies: 3
    Last Post: 06-12-2013, 02:01 AM
  3. Replies: 3
    Last Post: 02-22-2013, 06:41 AM
  4. Automatic backup
    By timpepu in forum Access
    Replies: 4
    Last Post: 08-14-2012, 01:38 PM
  5. Automatic Flagging
    By terricritch in forum Access
    Replies: 4
    Last Post: 09-14-2010, 06:03 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