Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329

    Bad File Name Or Number

    Hi Guy's i am trying to copy a jpg image from a camera SD card, and camFile is coming up with bad file name or number

    When i hover over the debug line (in Bold) the camFile is DSC*.* and not the rest of the file name ?



    I currently have an image called DSC00482 but the wildcard of *.* doesn't appear to work ?

    Code:
    If Me.cboImages = "From Camera" ThenCustName = Me.cboDealerIndex7
    DriveSelect = Forms!frmMainMenu!cboDrive
    CamPath = DriveSelect & "\DCIM\101MSDCF\"
    CamFile = "DSC & *.*" IS WILDCARD CORRECT
    Dest = "Collections"
    AccPath = "T:\My Customer\DMT 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
    NewName = CustName & "-" & Format(Now(), "dd-mm-yy") & ".jpg"
    Name CamPath & CamFile As imgPath & NewName (camFile is bad file name or number)
    'Clear Camera
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set ObjFiles = FSO.GetFolder(CamPath).Files
    imgQty = ObjFiles.Count
    x = 1
    Do Until CamFile = vbNullString
    CamFile = Dir
    x = x + 1
    Loop
    MsgBox ("Camera SD Card Is Now Empty, Please Remove SD Card From Computer"), vbInformation + vbOKOnly, "SD CARD NOW CLEAR"
    End If

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,280
    Still not indenting code I see :-(

    You do not say where you are hovering?, and you set camFile to that value yourself?
    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. #3
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    Your code says
    CamFile = "DSC & *.*" IS WILDCARD CORRECT

    Shouldn't that be
    CamFile = "DSC" & "*.*"
    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 ↓↓

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,280
    How are you deleting the images from the card as well?
    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. #5
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    Hi, thank you and yes to all, it's the file name but after changing the wildcard, the filename still returns bad file name or number

    I am testing step by step so the code in the image is meant to copy the file from SD Card to accPath then delete the file from SD Card

    What my target is following that is

    Open accPath And New FileName in msPaint (so i can resize the image)
    manually save and close
    attach to email

    This is the debug line: (note i have scrubbed out Customer Folder on here)

    Click image for larger version. 

Name:	Capture.JPG 
Views:	10 
Size:	72.2 KB 
ID:	45742

  6. #6
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    Add a

    Code:
    Debug.Print  "File Name: " & CampPath & CamFile , "Target: " & imgPath & NewName
    before the error line, and examine the contents.

    BTW a picture of your code doesn't make for easy assistance. Copy paste and then redact by putting in xxxxx or similar.
    Also the code as presented doesn't compile as there is an extra End IF at then end.

    I'm not sure you can use a wildcard in a renaming action either.
    Have you tried it on the command line or in the immediate window as a test?
    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 ↓↓

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,280
    I think you need to use the DIR() function to walk through the folder and rename the files one at a time.?
    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. #8
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    Hi Guy.s thank you, added the debug.Print line still highlights as image and what i should have mentioned, there is ever only 1 image to resize, email and relocate

    Kindest

  9. #9
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    In the immediate window, what did the debug.print output display?
    (Press ctrl + G to bring it up)
    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 ↓↓

  10. #10
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    Hi Minty, this is debug.Print in the immediate window (removed Customer name on here) Note: i have tried using fso to get file name but the file name on a msgbox is DSC*.* the same as the immediate window

    File Name: DSC*.* Target: T:\Images\Collections\Dealer Name removed\Dealer Name Removed-13-07-21.jpg

    here is the file in the folder


    Click image for larger version. 

Name:	Capture.JPG 
Views:	10 
Size:	136.2 KB 
ID:	45744

  11. #11
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    Your filename appear to be missing the full path, so that won't work.
    Drive Select appears to not be getting set to anything. It should be

    E:\DCIM\101MSDCF\

    What happens if you simply hard code the names as a test ?

    Name "E:\DCIM\101MSDCF\DSC*.*" as "T:\Images\Collections\Dealer Name removed\Dealer Name Removed-13-07-21.jpg"
    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 ↓↓

  12. #12
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    Ahh thanks Minty, i will give that a try

  13. #13
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    Hi minty, the following line is coming up bad file name again (bearing in mind, the cboDealerIndex7 has got a CustName

    Code:
    NewName = CustName & "-" & Format(Now(), "dd-mm-yy") & ".jpg"
    Debug.Print "File Name: " & CamPath & CamFile, "Target: " & imgPath & NewName
    'Name CamPath & CamFile As imgPath & NewName
    Name "E:\DCIM\101MSDCF\DSC*.*" As imgPath & NewName

  14. #14
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    Whatever i change the CamFile to either:

    DSC"*.*"

    Or DSC & "*.jpg"

    Or DSC & "*.*"

    When i MsgBox The CamFile, it is exactly as the examples above

    I just can't seem to return the filename in this case DSC00482.jpg

    Click image for larger version. 

Name:	Capture.JPG 
Views:	9 
Size:	35.3 KB 
ID:	45745

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,280
    You cannot use * with Name
    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 1 of 2 12 LastLast
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