A family of Microsoft relational database management systems designed for ease of use.
Try this --
Mid([YourField], InStrRev([YourField], " ")+1)
Or if the last segment may have spaces --
Mid([YourField], InStrRev([YourField], ",")+2)
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to extract the last portion of a field with a number of ID's of varying lengths separated by a comma. Eg;
ERT43, GHY3, 876
WEDV5, 32, 1KT9, COIU75643
QWSDC8765, 57Y9
I have tried using the right and instr functions without returning the correct result. I need the final ID after the last comma.
thanks
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
Try this --
Mid([YourField], InStrRev([YourField], " ")+1)
Or if the last segment may have spaces --
Mid([YourField], InStrRev([YourField], ",")+2)
Answer accepted by question author
The ParseWord() function from this page may help:
http://allenbrowne.com/func-10.html
You would use it like this:
=ParseWord([YourFieldNameHere], -1, ",")
Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to forum, rather than allenbrowne at mvps dot org.
Answer accepted by question author
Easiest way would be a simple VBA function to return the last item
Public Function fgetLastItem(strIn)
Dim vStr As Variant
If Len(strIn & "") = 0 Then
fgetLastItem = strIn
Else
vStr = Split(strIn, ",")
fgetLastItem = vStr(UBound(vStr))
End If
End Function
Save that in a VBA module and call it where needed
John Spencer Access MVP 2002-2005, 2007-2010 The Hilltop Institute University of Maryland Baltimore County