Results 1 to 3 of 3
  1. #1
    laniebe is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    17

    Talking Set unbound Textbox with a date format to previous Friday

    Hello! to put this simply, I have a form with an unbound textbox that is used to enter a date. I want the default in that textbox (titled: DateWorked) to always be the previous Friday. This is a form used for employee time entry, the billing periods always ends on Friday, so that is the reasoning.



    As the user selects the employees from a listbox, an append query runs to add the employee selected to the tblTimeClock. The append query copies the EmployeeID and DateWorked to the tblTimeClock.

    Please let me know what else I can provide!!

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    In the control source property of the text box control "DateWorked", try
    Code:
    =DateAdd("d",-Weekday(Date())-1,Date())

  3. #3
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    how 'bout:
    usage: txtbox.default = getStartOFWeek(Date())

    Code:
      'give any date and get the date that starts the week
    Public Function getStartOFWeek(ByVal pvDate) As Date
    Dim iDow As Integer, iSTARTDAY As Integer
    Dim i As Integer
    iSTARTDAY = vbFriday
    'iSTARTDAY = Range("I2").Value
    iDow = Format(pvDate, "w")
    Select Case True
       Case IsNull(pvDate)
         getStartOFWeek = Null
       Case iDow = iSTARTDAY
         getStartOFWeek = pvDate
      Case Else
         i = iSTARTDAY - iDow
         If i > 0 Then i = i - 7
         getStartOFWeek = DateAdd("d", i, pvDate)
    End Select
    End Function

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

Similar Threads

  1. Replies: 12
    Last Post: 12-25-2015, 12:47 AM
  2. Calculate last 4 weeks (Friday to Friday)
    By Astron2012 in forum Queries
    Replies: 2
    Last Post: 11-29-2013, 04:08 PM
  3. Replies: 2
    Last Post: 10-14-2013, 08:24 AM
  4. Replies: 8
    Last Post: 04-12-2013, 08:59 PM
  5. Select the First friday after a date
    By lucasjkr in forum Queries
    Replies: 1
    Last Post: 11-13-2012, 03:07 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