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 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 ↓↓
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
Hi Guy's all sorted, thank you all so much for your input
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
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![]()
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
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
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