Solved

How to replace first character in a string in Access 97

Posted on 2011-03-18
5
429 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

623 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