Solved

How to replace first character in a string in Access 97

Posted on 2011-03-18
5
412 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
Comment Utility
I think you have realised that the replace function is not available.

here is an Alternative
0
 

Author Comment

by:chtullu135
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now