Results 1 to 7 of 7

Thread: Need help with strings in vba vb access

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    23

    Need help with strings in vba vb access

    First off I just wanted to say thanks to all the people that helped so far. I have been developing in vba for the past 3 weeks and have a pretty firm understanding of it. Well anyways heres my problem.

    Im saving a date string in this format ("11/14/05") as part of the title of a excel spreadsheet I am generating from access.

    The problem:You cant save a filename under this format obviously. So I want to change:

    11/14/05 to 11_14_05

    So basically I need the char position the concatinate & "_" where the "/" would have been. What is the correct syntax to do this in vba/visual basic access?

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Need help with strings in vba vb access

    Use the replace function.
    Here's an example.

    VB Code:
    1. Private Function NewDate(OldDate As String) As String
    2.     NewDate = Replace(OldDate, "/", "_")
    3. End Function
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    23

    Re: Need help with strings in vba vb access

    I like it! Thank you. Is there a way to physically change strings for future reference?

    _Stephen

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Need help with strings in vba vb access

    Change them into what?
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    23

    Re: Need help with strings in vba vb access

    Oh I meant is there a way to pick out the certain characters you want to display.

    _Stephen

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    23

    Re: Need help with strings in vba vb access

    BTW I used that replace and it worked wonders. Now I just need to find out how to populate the excel spreadsheet off of a subform.

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need help with strings in vba vb access

    To make the string variable retain the change...
    VB Code:
    1. MyDate = Replace(MyDate, "/", "_")
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width