I am trying to use the InStrRev function in a query and am getting the error message:
"Undefined function 'InStrRev' in expression."
I have a field in a table that contains student register marks as a continuous string.
eg. O///O//OO
/ - attended
O - absent
From this string I am trying to find the first and last attendance mark.
To find the first I am using:
which works fine.

To find the last I thought I would be able to use:
but, although I have followed the syntax advice in the help file it doesnot seem to work.

Any ideas
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

use this


Hello mjwerner,

Your example works fine for me in a query in A2003.  What version of Access are you using?

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
What version of Access are you using? I've had similar problems (functions which I know are valid show up as errors, just like you are experiencing). Often this indicates corruption. Try typing this in the Immediate window (Ctrl + G will bring up the window):


and see what gives. You may want to try and compile your project (Debug - Compile) and see if you receive any errors; also, a compact/repair would be advised.

Before doing any of this, of course, make a copy of your database.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

mjwernerAuthor Commented:
1. I am using Access2k

2. InStr(1,[REGT_Attendance_Pattern],"/",-1) does not work.

3. I am not using vba code, just a query expression.

It appears that in A2000 Instrrev is only implemented in VBA and not in the Access UI.
So to get roound this you create your own function wrapper and use that instead:

In a standard module:

Public Function MyInStrRev(pString, pSearchFor)
myinstrrev = InstrRev(pstring, psearchfor)
End Function


Not sure if I made it clear that  you can then use MyInstrRev() in the Access query grid.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mjwernerAuthor Commented:
Nice one, works a treat.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.