Acess VBA: How do I replace reserved characters in a string?

Posted on 2011-10-19
Last Modified: 2012-06-27
I am using the OutputTo method in Access. I want to strip the reserved characters for naming Windows files in a string and replace them with a string that does not cause an error.

Example: report name to export is "10/19/11 Inventory, Current". I want to rename as "10-19-11_Inventory_Current".

Question by:CafeTica
    LVL 119

    Expert Comment

    by:Rey Obrero
    open the db, and select the Report, then hit F2 and change the name

    or right click on the Report and then select Rename

    Author Comment

    LVL 119

    Accepted Solution

    dim stDocName

    strDocName="10/19/11 Inventory, Current"

    strDocName=replace(replace(replace(strDocName,"/","-"),", ","_")," ","_")

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now