Solved

How to replace first character in a string in Access 97

Posted on 2011-03-18
5
416 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 19

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 19

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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.
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

770 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