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 Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
IIF Count InStr and InStrRev in standard query
Bryon Relyea 
       
2 years ago
I've previously received guidance on using InStr and InStrRev to remove an unwanted string from a field, after "-", while in a standard query. Is there a way to use an "IIF" and "Count" function in a standard query to determine whether to use InStr (single "-") or InStrRev (multiple "-")?

I have the following:
TruncatedField: IIf(Count([TableName].[Field],"-" = 1, Left([TableName].[Field] & "-",InStr([TableName].[Field] & "-","-")-1), Left([TableName].[Field], InStrRev([TableName].[Field], "-",-1))))

I receive a "wrong number of arguments" error message; and cannot see where the error is.

Thank you!!!
Kevin Robertson  @Reply  
           
2 years ago
Use this formula to count the number of hyphens in your string.

HyphenCount: Len([MyString])-Len(Replace([MyString],"-",""))
Kevin Robertson  @Reply  
           
2 years ago

Bryon Relyea OP  @Reply  
       
2 years ago
hello, Kevin -

Thank you for the quick response. That solution was definitely not one that I was expecting. However, it is much easier to read than my tangled mess.

As always, I appreciate your assistance and expertise!

Bryon

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access 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 6:03:24 AM. PLT: 1s