473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do you strip off trailing characters using Microsoft Access

With 2 separate character strings of
100038_ko and 244p_po how do I strip off the _ko and _po from the respective strings?
Sep 23 '10 #1
6 6673
gnawoncents
214 100+
You can use a replace function, or simply a length and left combined (assuming it is always a given number of characters to remove) e.g.

Expand|Select|Wrap|Line Numbers
  1. myString = Left(myString, Len(myString) - 3)
  2.  
Sep 23 '10 #2
In addition to xxxxxx_po and xxx_fr I have other names in the list like xxxxxxxx without the extension. Would the replace function work better since what you sent me would remove the last 3 characters whether the extensions (ie)_po, _fr, existed or not. Of course I would not want to delete the last 3 characters unless the _xx actually existed.
Sep 23 '10 #3
Mariostg
332 100+
Expand|Select|Wrap|Line Numbers
  1. x = "xxxxxx_po"
  2. If InStr(x, "_") Then
  3.     x = Left(x, InStr(x, "_") - 1)
  4. End If
  5.  
Only strips if _ is in the string.
Sep 23 '10 #4
Can I get a free upgrade for my Micrsoft Access to run IF statements? IF not for free, what should I use?
Sep 23 '10 #5
gnawoncents
214 100+
Can I get a free upgrade for my Micrsoft Access to run IF statements? IF not for free, what should I use?
Ken, I'm not sure what you're asking....

Regarding using replace vs. an If statement, it all depends on the strings in question. If there is ALWAYS an underscore in the data to be removed (_) and you ALWAYS want to get rid of it and any trailing characters, Mariostg's suggestion should work great.

If there is not always an underscore, but there are only a handful of different trailing characters, either an If statement or Replace would work fine.
Sep 23 '10 #6
Stewart Ross
2,545 Expert Mod 2GB
Please note that the IF statement mentioned above is a VBA statement that would be used in a custom function in a VBA code module.

To use an IF in a query without calling a VBA function you need the in-line version called IIF:

Expand|Select|Wrap|Line Numbers
  1. TrimmedField: IIF(InStr([YourFieldName], "_") > 0, Left([YourFieldName], InStr([YourFieldName], "_") - 1), [YourFieldName])
-Stewart
Sep 23 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Victoria Holowchak | last post by:
I was hoping that Microsoft Access 2002 would allow users to see all the columns of an Oracle database table that contained more than 255 columns. I noticed that my Oracle8 ODBC driver is only at...
17
by: Pam Ammond | last post by:
I need to use Microsoft Access Automation within a Visual Studio 2003 program written in C# for Windows Forms. When a button is clicked in my VS.NET program, I want it to run a Microsoft Access...
5
by: Hannie | last post by:
I am currently doing my project using VB.NET I have a database which contains all my data that the user key in. The problem is, when i click the retrieve button on the form, the details that the...
3
by: Rob Hill | last post by:
I am using Microsoft Access as a prototype for a database application that will eventually be rewritten in VB.NET. I would like to use Access for prototyping future versions of the application. ...
1
by: dhussong | last post by:
I am attempting to use Visual Studio 2005 (Visual Basic) and the Enterprise Library 2.0 Data Access Application Block with a Microsoft Access database. I know the names of my Access databases but I...
1
by: glenn | last post by:
Hi folks, Have read a bit on this topic but so far no positive results. I have the following table named 'discussions': id discussionNumber from to status 1 1 ...
23
by: Steven TK | last post by:
Hi everyone, I wonder who can help me on the filter the Start Date and End Date. I still cannot manage to filter it. Eg. When the user click the StartDate(comboBox as 16/7/07), the Start...
1
by: mcVBNet10 | last post by:
I am working on a project in VB.Net using access as backend. But I wanted to take advantage of access reporting power. Therefore I was trying to see if I could open an Access Report (Built inside of...
1
by: BharathP | last post by:
Hi, I need to transfer data of one of the table in DB2 to Microsoft Access. I tried using DBOP data source using Configuration assistant in DB2 and SQL passthrough in Microsoft Access. I think I'm...
1
by: BharathP | last post by:
Hi, I need to transfer data of one of the table in DB2 to Microsoft Access. I tried using DBOP data source using Configuration assistant in DB2 and SQL passthrough in Microsoft Access. I think I'm...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.