Number format into ordinal number (1st, 2nd, 3rd, 4th) displayed on form | access VBA (1 Viewer)

Ihk

Member
Local time
Today, 23:15
Joined
Apr 7, 2020
Messages
280
Table1
I have a table with a number field.
Form1
I have data entry form with that control bound to that table. This control is hidden on form, but has DMAX before update. So numbers keep increasing, while user enter data in the table via that form.
Form2
Now I want these numbers to be displayed on another form as ordinal number format like 1st, 2nd, 3rd, 4th etc instead of 1,2,3,4.
How can I get that?
thanks
 
Last edited:

plog

Banishment Pending
Local time
Today, 16:15
Joined
May 11, 2011
Messages
11,636
Now I want these numbers to be stored as ordinal number format like 1st, 2nd, 3rd, 4th etc instead of 1,2,3,4.

I don't think you do. I bet you want to display them in ordinal format. Big difference.

You change it to a text field and store "5th" and it gets much more difficult to calculate the next number. Right now you use math to grab the biggest number in the database, use math to add one. With a text field, math goes away. Stored as text, "9th" is after "10th". Your system breaks after 10 positions. And that's not even mentioning having to strip the "th (or possibly the "st", "nd" or "rd")" off each number so that you can determine what to add one to, followed by adding the "th" (or possibly the "st", "nd" or "rd") back to that new number.

Keep it as a number and use a function to display that number as you wish.
 
  • Like
Reactions: Ihk

Ihk

Member
Local time
Today, 23:15
Joined
Apr 7, 2020
Messages
280
I don't think you do. I bet you want to display them in ordinal format. Big difference.

You change it to a text field and store "5th" and it gets much more difficult to calculate the next number. Right now you use math to grab the biggest number in the database, use math to add one. With a text field, math goes away. Stored as text, "9th" is after "10th". Your system breaks after 10 positions. And that's not even mentioning having to strip the "th (or possibly the "st", "nd" or "rd")" off each number so that you can determine what to add one to, followed by adding the "th" (or possibly the "st", "nd" or "rd") back to that new number.

Keep it as a number and use a function to display that number as you wish.
You are right and I agree, want to display.
Because i want to have positions or ranks.
So I am going edit my original post.
Thanks for pointing out.
 

plog

Banishment Pending
Local time
Today, 16:15
Joined
May 11, 2011
Messages
11,636
I provided that answer as well--you build a function. You pass it a number, it returns a string of it correctly formatted. I am sure if you search the forum that code has been written and posted on here before (although its pretty simple to roll your own and would be a great introduction to VBA programming.)
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 17:15
Joined
Apr 27, 2015
Messages
6,319
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 22:15
Joined
Sep 12, 2006
Messages
15,634
fwiw, you would think there would be a format setting to display a number in it's ordinal form, wouldn't you? (Edit. But there isn't)
 
Last edited:

Users who are viewing this thread

Top Bottom