Results 1 to 3 of 3
  1. #1
    Josha is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2019
    Location
    Victoria, Australia
    Posts
    42

    How to replace all instances of '/' in a string function?

    So in my Access database I have two fields for my science students ;

    Field #1: contains the students case number. The field is called [CaseNumber]
    Field #2: contains the students examination date. The field is called [ExaminationDate]

    In a separate unbound field on the form called [ReportName] the Control Source has the following :

    Code:
    =[CaseNumber] & [ExaminationDate] & "Notes"



    So if the case number was 1234/2022 and the date was 2022.02.10 then the [ReportName] will automatically display : 1234/2022 2022.02.10 Notes.

    Which is fantastic ! However, I want the [ReportName] field to replace any instance of "/" (forward slash) to a "-" (dash)...... So that the [ReportName] field would auto display 1234-2022 2022.02.10 Notes.

    Is there a way I can do this? With a replace function? in VBA maybe? I don't know?

    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Yes, use Replace() function.

    If you don't want to actually change the saved data, just calculate in query or textbox. And you probably need to Format date. Don't forget separating spaces.

    Replace([CaseNumber], "/", "-") & " " & Format([ExaminationDate], "yyyy.mm.dd") & " Notes"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Josha is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2019
    Location
    Victoria, Australia
    Posts
    42
    That was so simple! It worked !

    Thank you for your reply

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

Similar Threads

  1. Call a function in instances of a form
    By MidNite in forum Access
    Replies: 7
    Last Post: 04-26-2021, 11:23 AM
  2. Store an operator and replace a string with it
    By Ruegen in forum Programming
    Replies: 14
    Last Post: 10-22-2014, 11:45 PM
  3. Replies: 3
    Last Post: 06-07-2012, 07:05 AM
  4. Issue Using Replace in SQL String
    By starryNight in forum Programming
    Replies: 15
    Last Post: 06-03-2011, 01:24 PM
  5. replace characters in a string
    By blazixinfo@yahoo.com in forum Access
    Replies: 6
    Last Post: 08-06-2009, 03:36 PM

Tags for this Thread

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