Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144

    I did suggest that a wildcard might not work in post #6.
    If there is only ever one file in that folder then simply get the whole filename using the Dir() function as suggested by WGM earlier.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  2. #17
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,275
    Quote Originally Posted by Minty View Post
    I did suggest that a wildcard might not work in post #6.
    If there is only ever one file in that folder then simply get the whole filename using the Dir() function as suggested by WGM earlier.
    I know Minty. Sometimes people have to be told more than once by different people.
    I actually tried it in the immediate window and got the same error, so that is why I said it will not work.

    TBH, I was not even sure it would move drives, but it does.?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #18
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    Hi Guy's all sorted, thank you all so much for your input

  4. #19
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,275
    Quote Originally Posted by DMT Dave View Post
    Hi Guy's all sorted, thank you all so much for your input
    So please post the working code (within tags), as it might help someone else in the future?, you never know.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #20
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    Hi welshgasman, i will post it, just doing another post now where i am trying to output a recordset to excel but trying to make the next record calculate from the last record

  6. #21
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    Working code for renaming images from SD Card To Designated Folder then cleaning the SD Card

    Code:
    Dim SrcPath As String, AccPath As String, CustPath As String, CustName As String, Dest As String, imgPath As String, SrcFile As String, OldName As StringDim i As Integer, imgQty As Integer, iRec As Integer
    Dim FSO As Object
    Dim DriveSelect As String, CamFile As String, StoreFile As String
    
    
    If Me.cboImages = "No" Then
    DoCmd.CancelEvent
    End If
    
    
    
    
    If Me.cboImages = "From Camera" Then
    CustName = Me.cboDealerIndex7
    DriveSelect = Forms!frmMainMenu!cboDrive
    SrcPath = DriveSelect & "\DCIM\101MSDCF\"
    CamFile = Dir(SrcPath & "DSC*.*")
    
    
    Dest = "Collections"
    AccPath = "T:\Cust Name\Images\" & Dest & "\" & CustName & "\"
    imgPath = "T:\Images\" & Dest & "\" & CustName & "\"
    
    
    If Dir(imgPath, vbDirectory) = "" Then
    MkDir (imgPath)
    Else
    DoCmd.CancelEvent
    End If
    
    
    If Dir(AccPath, vbDirectory) = "" Then
    MkDir (AccPath)
    Else
    DoCmd.CancelEvent
    End If
    
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set ObjFiles = FSO.GetFolder(SrcPath).Files
    imgQty = ObjFiles.Count
    If MsgBox("Camera SD Card File Quantity Confirmed = " & imgQty & vbNewLine & vbNewLine & _
    "Rename Files Now ?", vbQuestion + vbYesNo, "FILE COUNT") = vbNo Then
    DoCmd.CancelEvent
    Else
    SrcFile = Dir(SrcPath & "*.*")
    x = 1
    Do Until SrcFile = vbNullString
    NewName = CustName & "-" & Format(Now(), "dd-mm-yy") & ".jpg"
    Name SrcPath & SrcFile As imgPath & NewName
    SrcFile = Dir
    x = x + 1
    Loop
    End If
    End If
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set ObjFiles = FSO.GetFolder(SrcPath).Files
    imgQty = ObjFiles.Count
    If MsgBox("Camera SD Card File Quantity Confirmed = " & imgQty & vbNewLine & vbNewLine & _
    "Rename Files Now ?", vbQuestion + vbYesNo, "FILE COUNT") = vbNo Then
    DoCmd.CancelEvent
    Else
    SrcFile = Dir(SrcPath & "*.*")
    x = 1
    Do Until SrcFile = vbNullString
    NewName = CustName & "-" & Format(Now(), "dd-mm-yy") & ".jpg"
    Name SrcPath & SrcFile As imgPath & NewName
    SrcFile = Dir
    x = x + 1
    Loop
    End If
    End If
    
    
    Dim lne As String
    lne = "..............................................................."
    If MsgBox("Files Transfered And Renamed as Follows:" & vbNewLine & vbNewLine & _
    lne & vbNewLine & vbNewLine & _
    "From SD Card: " & SrcPath & vbNewLine & vbNewLine & _
    lne & vbNewLine & vbNewLine & _
    "To: " & imgPath & vbNewLine & vbNewLine & _
    lne & vbNewLine & vbNewLine & _
    "New Files Are: " & NewName & vbNewLine & vbNewLine & _
    lne & vbNewLine & vbNewLine & _
    "Camera SD Card Is Now Empty,Please Remove From The Computer" & vbNewLine & vbNewLine & _
    lne & vbNewLine & vbNewLine & _
    "Resize Image Now ?", vbInformation + vbYesNo, "CONFIRM FILES") = vbNo Then
    DoCmd.CancelEvent
    Else
    Shell Chr(34) & "C:\Windows\System32\mspaint.exe" & Chr(34) & " " & _
    Chr(34) & imgPath & NewName & Chr(34), 1
    End If

  7. #22
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,275
    Quote Originally Posted by DMT Dave View Post
    Hi welshgasman, i will post it, just doing another post now where i am trying to output a recordset to excel but trying to make the next record calculate from the last record
    See if this helps?
    Code:
    SELECT Emails.ID, Emails.TransactionDate, Emails.CMS, Emails.Client, Emails.Amount, DSum("[Amount]","Emails","[CMS]=" & [CMS] & " AND ID < " & [ID]) AS PrevBal, [Amount]+nz([PrevBal],0) AS NewBal, DSum("[Amount]","Emails","[CMS]=" & [CMS] & " AND TransactionDate < #" & [Transactiondate] & "#") AS PrevBalDate
    FROM Emails
    ORDER BY Emails.ID, Emails.TransactionDate, Emails.CMS;
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #23
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,275
    And for anyone that wants to read it
    Code:
    Sub WhateverYouWantToCallIt()
        Dim SrcPath As String, AccPath As String, CustPath As String, CustName As String, Dest As String, imgPath As String, SrcFile As String, OldName As String
        Dim i As Integer, imgQty As Integer, iRec As Integer
        Dim FSO As Object
        Dim DriveSelect As String, CamFile As String, StoreFile As String
    
    
        If Me.cboImages = "No" Then
            DoCmd.CancelEvent
        End If
    
    
    
    
        If Me.cboImages = "From Camera" Then
            CustName = Me.cboDealerIndex7
            DriveSelect = Forms!frmMainMenu!cboDrive
            SrcPath = DriveSelect & "\DCIM\101MSDCF\"
            CamFile = Dir(SrcPath & "DSC*.*")
    
    
            Dest = "Collections"
            AccPath = "T:\Cust Name\Images\" & Dest & "\" & CustName & "\"
            imgPath = "T:\Images\" & Dest & "\" & CustName & "\"
    
    
            If Dir(imgPath, vbDirectory) = "" Then
                MkDir (imgPath)
            Else
                DoCmd.CancelEvent
            End If
    
    
            If Dir(AccPath, vbDirectory) = "" Then
                MkDir (AccPath)
            Else
                DoCmd.CancelEvent
            End If
    
    
            Set FSO = CreateObject("Scripting.FileSystemObject")
            Set ObjFiles = FSO.GetFolder(SrcPath).Files
            imgQty = ObjFiles.Count
            If MsgBox("Camera SD Card File Quantity Confirmed = " & imgQty & vbNewLine & vbNewLine & _
                      "Rename Files Now ?", vbQuestion + vbYesNo, "FILE COUNT") = vbNo Then
                DoCmd.CancelEvent
            Else
                SrcFile = Dir(SrcPath & "*.*")
                X = 1
                Do Until SrcFile = vbNullString
                    NewName = CustName & "-" & Format(Now(), "dd-mm-yy") & ".jpg"
                    Name SrcPath & SrcFile As imgPath & NewName
                    SrcFile = Dir
                    X = X + 1
                Loop
            End If
        End If
    
        Set FSO = CreateObject("Scripting.FileSystemObject")
        Set ObjFiles = FSO.GetFolder(SrcPath).Files
        imgQty = ObjFiles.Count
        If MsgBox("Camera SD Card File Quantity Confirmed = " & imgQty & vbNewLine & vbNewLine & _
                  "Rename Files Now ?", vbQuestion + vbYesNo, "FILE COUNT") = vbNo Then
            DoCmd.CancelEvent
        Else
            SrcFile = Dir(SrcPath & "*.*")
            X = 1
            Do Until SrcFile = vbNullString
                NewName = CustName & "-" & Format(Now(), "dd-mm-yy") & ".jpg"
                Name SrcPath & SrcFile As imgPath & NewName
                SrcFile = Dir
                X = X + 1
            Loop
        End If
    End If
    
    
    Dim lne As String
    lne = "..............................................................."
    If MsgBox("Files Transfered And Renamed as Follows:" & vbNewLine & vbNewLine & _
              lne & vbNewLine & vbNewLine & _
              "From SD Card: " & SrcPath & vbNewLine & vbNewLine & _
              lne & vbNewLine & vbNewLine & _
              "To: " & imgPath & vbNewLine & vbNewLine & _
              lne & vbNewLine & vbNewLine & _
              "New Files Are: " & NewName & vbNewLine & vbNewLine & _
              lne & vbNewLine & vbNewLine & _
              "Camera SD Card Is Now Empty,Please Remove From The Computer" & vbNewLine & vbNewLine & _
              lne & vbNewLine & vbNewLine & _
              "Resize Image Now ?", vbInformation + vbYesNo, "CONFIRM FILES") = vbNo Then
        DoCmd.CancelEvent
    Else
        Shell Chr(34) & "C:\Windows\System32\mspaint.exe" & Chr(34) & " " & _
              Chr(34) & imgPath & NewName & Chr(34), 1
    End If
    
    End Sub
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Bad File Name Or Number
    By DMT Dave in forum Access
    Replies: 3
    Last Post: 06-07-2021, 10:35 AM
  2. Replies: 1
    Last Post: 06-07-2020, 07:59 PM
  3. bad file name or number error
    By lolibooki in forum Access
    Replies: 4
    Last Post: 09-25-2013, 12:46 AM
  4. auto fill name based on file number
    By mark_w in forum Forms
    Replies: 13
    Last Post: 08-03-2012, 04:59 AM
  5. count number of file names within a folder containing
    By dumbledown in forum Programming
    Replies: 2
    Last Post: 04-24-2012, 02:55 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