Solved

How to replace first character in a string in Access 97

Posted on 2011-03-18
5
422 Views
Last Modified: 2012-05-11
Hello,

I need to replace the first character in a string.  The attached code, placed within query design grid works.  However the client wants to replace the first character in a string based on certain conditions where TO Description] Like "Extended *",fnReplace[(WBS5])",  I tried to use a built in replace function, however Access 97 doesn't seem to have one.    Thanks

AdjWBS5: Switch([TO Description] Like "LWTS *","2.01.04.70436",[TO Description] Not Like "LWTS *" Or [TO Description] Like "*Extended*",[WBS5])

Open in new window

0
Comment
Question by:chtullu135
  • 3
  • 2
5 Comments
 
LVL 20

Accepted Solution

by:
darbid73 earned 500 total points
ID: 35165946
I think you have realised that the replace function is not available.

here is an Alternative
0
 

Author Comment

by:chtullu135
ID: 35166095
Thanks for the information.  I've done some more work and I think the following will work for my purpose since I just need to replace the first character.  However, the code you linked to should be useful in the future

Public Function ReplaceStr(strInput As String, strReplacement As String) As String
Dim strResult As String    
   
        strResult = strReplacement & Mid(TextIn, 2, Len(strInput))
        ReplaceStr = strResult
       
   
End Function
0
 
LVL 20

Expert Comment

by:darbid73
ID: 35166392
No arguments from me. I could think of many ways to do it like you. The RIGHT function would also do it. You might find that for a REPLACE function for 97 that the code I gave you is the most flexible.
0
 

Author Comment

by:chtullu135
ID: 35166688
Thanks for your help,  I'll store the function you linked to in my bag of codes snippets.  It will definitely come in useful.  By the way, I looked at the data again and noticed that there was a field of the data that that was an extended version of the result I wanted so I used a MID function to get the correct data.  I'll go ahead and give you the points for the useful tips you gave me.
AdjWBS5: Switch([TO Description] Like "LWTS *","2.01.04.70436",[TO Description] Not Like "LWTS *" And [TO Description] Not Like "*Extended*",[WBS5],[TO Description] Like "*Extended Support*",Mid([WBS7],1,16))

Open in new window

0
 

Author Closing Comment

by:chtullu135
ID: 35166692
Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

827 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