Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
remove chars after 2nd dash
Bryon Relyea 
       
3 years ago
Good morning, my access gurus -

I'm familiar with the test to remove characters after a dash/hyphen in my data sets. However, I have 5 stinking products which actually have two dashes in their format. How would I adjust the code below to remove data after the second dash?

Code:
Left([TableName].[FieldName] & "-",InStr([TableName].[FieldName] & "-","-")-1)

As always, thank you for your time and assistance!!!
Alex Hedley  @Reply  
           
3 years ago
Can you share an example of the original data and the expected outcome?
Bryon Relyea OP  @Reply  
       
3 years ago
Original:   ABCD-1234-56789

Desired Outcome: ABCD-1234

these are product SKUs, where the ABCD-1234 is the same for all products, and the '56789' is a specific package size.  

I want to remove the package sizes from all material because other associated data elements are the same regardless of package size. removing the pack size will allow for removal of redundant info.
Alex Hedley  @Reply  
           
3 years ago
InStrRev should be able to get the last '-' then just do Left() to that position.
Bryon Relyea OP  @Reply  
       
3 years ago
So, do I just replace "InStr" with "InStrRev" ?
Alex Hedley  @Reply  
           
3 years ago
Untested, give it a go.
You want to find the pos of the '-' and then get all the text up until that.
Did you watch the linked video?

Code:
Left([TableName].[FieldName], InStrRev([TableName].[FieldName], "-")-1)
Bryon Relyea OP  @Reply  
       
3 years ago
Thanks, Alex!  will give it a try in a bit, and let you know how it goes.
Bryon Relyea OP  @Reply  
       
3 years ago
Hello, Alex -

THANK YOU!!  this worked perfectly.  output is exactly what I needed.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/8/2026 8:12:02 PM. PLT: 1s