Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to replace first character in a string in Access 97

Posted on 2011-03-18
5
Medium Priority
?
449 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 2000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

926 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