Results 1 to 6 of 6
  1. #1
    templeowls is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    305

    Trim file name to remove extension

    I'm using 'Application.CurrentProject.Name' in VBA to populate my DB's file name, but it's (understandingly) including the file's extension (.accdb).



    Any suggestions on code to remove that? (Basically remove everything after the period, including the period itself)

  2. #2
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    232
    Combine the InStrRev function (find the ".") and the Left function (part in front of the ".") in one expression.
    Groeten,

    Peter

  3. #3
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    232
    Or use the Replace function to replace ".accdb" with "".
    Groeten,

    Peter

  4. #4
    templeowls is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    305
    Quote Originally Posted by xps35 View Post
    Combine the InStrRev function (find the ".") and the Left function (part in front of the ".") in one expression.
    Gotcha. So I tried the below but am getting a 'external name not defined error on the 'application.currentproject.name'. Any suggestions?

    Code:
    Left([Application.CurrentProject.Name], InStrRev([Application.CurrentProject.Name], ".") - 1)

  5. #5
    templeowls is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    305
    Nvm. Just needed to get rid of the brackets. Thanks!

  6. #6
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    nevermind deleted.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

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

Similar Threads

  1. File address and extension
    By kolait in forum Access
    Replies: 15
    Last Post: 08-18-2021, 06:07 PM
  2. file format or extension not valid.
    By Homegrownandy in forum Programming
    Replies: 6
    Last Post: 02-05-2018, 07:24 AM
  3. Use FileDialog to get file with txt extension
    By newbieX in forum Programming
    Replies: 4
    Last Post: 01-11-2016, 07:28 PM
  4. Need to import .txt file using the extension only.
    By PJ Crittenden in forum Macros
    Replies: 3
    Last Post: 06-24-2014, 07:10 PM
  5. access file extension help
    By supertech33 in forum Access
    Replies: 2
    Last Post: 02-17-2010, 03:31 PM

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