Results 1 to 3 of 3
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195

    Replacing folders

    Hi Guys, i have a command button that will add Date folders to a specific loaction, i was wondering if I can replace these folders with new one's once that date has expired, these folders are named With DayName Day/Month/Year, the date is taken from a text box (txtDate) ie:



    Dim FldPath as String
    Dim FldWed as String
    Dim FldSun As String

    FldPath = "T:\folderA\FolderB"
    FldWed = FldPath & Format(Me.txtDate,"ddd-dd-mm-yyyy") ' CAN THIS BE AUTO NEXT AVAILABLE WEDNESDAY AND NOT USE TEXT BOX DATE ??
    FldSun = FldPath & Format(Me.txtDate,"ddd-dd-mm-yyyy") ' CAN THIS BE AUTO NEXT AVAILABLE SUNDAY
    AND NOT USE TEXT BOX DATE ??

    If Dir(FldPath & FldWed, vbDirectory) <>"" Then
    DoCmd.CancelEvent
    Else
    MkDir(FldPath & FldWed)
    End IF

    If Dir(FldPath & FldSun, vbDirectory) <>"" Then
    DoCmd.CancelEvent
    Else
    MkDir(FldPath & FldSun)
    End IF

    Let's Say FldWed = Wed-06-06-2018

    Once Todays Date becomes the 7th June 2018

    I know there is RmDir Function to remove folder and files, is there a way of Coding this to pop up a msgbox something like:

    You Have got a folder dated (FldWed), As it is now Thursday 7th, Do you want to remove this folder and contents and add a new Wednesday Folder for next week ?

    If Yes, Find next Wednesday's date

    MkDir (next Wednesdays date)

    RmDir Yesterdays Date

    Many thanks

    Dave

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Review https://superuser.com/questions/3766...of-the-current

    That provides examples of calculating date for a day of the current work. To get the date for same weekday (such as Wednesday) for next week, add 7 to the current week expression.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    So what you are missing. Theres a function called Weekday. You can do some really good stuff with it. Made this just for ya

    Code:
    Private Function GetNextWednesday() As Date
        Dim dteTemp As Date: dteTemp = Now() ' Current Date
        GetNextWednesday = dteTemp + (9 - Weekday(Now())) ' Next Monday
        GetNextWednesday = GetNextWednesday + 2 ' Two Days After Monday
    End Function
    Public Sub DoTheTHing()
        If MsgBox("You have a folder dated " & _
                        vbCrLf & vbCrLf & _
                        strFolder & vbCrLf & _
                        "As It is now Thursday do you want to remove this folder " & _
                        "and contents and add a new wednesday folder for next week?", vbYesNo) = vbYes Then
        
            Dim dteTemp As Date: dteTemp = GetNextWednesday
            Debug.Print "Next Wednesday: " & dteTemp
            'mkdir your stuff
            'rmdir think you know this part
            
        End If
    End Sub

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

Similar Threads

  1. Create folders
    By slimjen in forum Modules
    Replies: 2
    Last Post: 04-04-2018, 08:38 AM
  2. Replies: 2
    Last Post: 05-24-2016, 04:54 PM
  3. List Folders
    By LonghronJ in forum Modules
    Replies: 4
    Last Post: 02-15-2016, 08:37 AM
  4. Deleting Folders
    By Madmax in forum Access
    Replies: 1
    Last Post: 10-05-2011, 11:02 AM
  5. Import from various folders
    By Statique in forum Import/Export Data
    Replies: 2
    Last Post: 07-02-2009, 06:10 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