Results 1 to 3 of 3
  1. #1
    Risto85 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014

    Macro to create new records from previous date until current week sunday


    I have a form where I would like to add button with functionality that checks the last date in table column B and adds new records with dates until current weeks sunday. For example if last record Date value is 20.10.2014 then it should create new records with date values until 26.10.2014

    Hope someone can help.

    best regards,

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    modify to fit your tables...

    'get 1st day of the week  'SUNDAY
    Public Function PostRecsTo1stDOW()
    Dim i As Integer, j As Integer
    Dim v1stDOW, vDate, vD
    vDate = DMax("*", "table")
     v1stDOW = vbSunday
     i = Format(vDate, "w")
     iEnd = 8 - i
     If i = v1stDOW Then
       get1stDOW = vDate
       get1stDOW = DateAdd("d", iEnd, vDate)
     End If
    docmd.setwarnings False
    For j = 1 To iEnd
       vD= dateadd("d",j,vDate)
        sSql = "INSERT INTO tTABLE ([dateFld]) values (#" & vD & "#)"
    docmd.setwarnings True
    End Function

  3. #3
    Risto85 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Thank you very much for helping out!

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

Similar Threads

  1. Macro using 'date' (current system date)
    By msmithtlh in forum Macros
    Replies: 4
    Last Post: 06-11-2014, 04:05 PM
  2. Replies: 2
    Last Post: 10-14-2013, 08:24 AM
  3. Replies: 3
    Last Post: 09-19-2013, 10:18 AM
  4. Replies: 9
    Last Post: 04-26-2013, 12:12 PM
  5. Replies: 3
    Last Post: 07-10-2011, 05:37 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