G
Guest
Anyone have a suggestion for easily formatting numbers as ordinals in an
Access report?
Muy thanks.
Access report?
Muy thanks.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Lynn Trapp said:This function should do what you want:
Function Ordinal_Numbers(P_Numeric As String) As String
Dim V_Ordinal As String
Dim V_Numeric As String
If Right(P_Numeric, 2) = "11" Or Right(P_Numeric, 2) = "12" Or
Right(P_Numeric, 2) = "13" Then
Ordinal_Numbers = "th"
Else
V_Numeric = Right(P_Numeric, 1)
Select Case V_Numeric
Case "1"
V_Ordinal = "st"
Case "2"
V_Ordinal = "nd"
Case "3"
V_Ordinal = "rd"
Case Else
V_Ordinal = "th"
End Select
Ordinal_Numbers = V_Ordinal
End If
End Function
Call the function from a query like this:
OrdinalNumber: [YourNumberField] & Ordinal_Numbers(CStr([YourNumberField]))
--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html
Lulu said:Formatting as Ordinal means if a value in a text box is 7 the value in the
report will read 7th; 11 would read 11th and 21 would read 21st
thanks.
Perhaps some future version of Access would think of this as a needed
Built-In Function.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.