Im not finding anything similar in the Posts so correct me if Im wrong...
Im real new to programing in Access (Been a while since I programed in anything). The question I have is.. How do you make letters increment?
It may sound weird but, I need to create unique numbers based on day and year. That part I can do. The last two Digits in the Number are two letters though ... AA through ZZ and I cant figure out how to get those to increment through all their values. i.e. AA,AB,AC,AD....ZY,ZZ.
Any ideas how to do this?
9 6496
Im not finding anything similar in the Posts so correct me if Im wrong...
Im real new to programing in Access (Been a while since I programed in anything). The question I have is.. How do you make letters increment?
It may sound weird but, I need to create unique numbers based on day and year. That part I can do. The last two Digits in the Number are two letters though ... AA through ZZ and I cant figure out how to get those to increment through all their values. i.e. AA,AB,AC,AD....ZY,ZZ.
Any ideas how to do this?
Unless someone else grasps this I cannot see in what context you are wanting to use it yes I understand the concept of AA then AB then AC for 26 repetitions on the A ........then onto B for 26 repetitions till we exhaust that then onto C and so on but in what real practical sense you wish to use it then.... No
If you merely want to have a viewable list of the combinations to work with then create a ONE field table add the letters of the alphabet to it and add this table to a query TWICE. do not join anything between the two tables simply run the query you will have a list of every possible combination. This is known in SQL parlance as a CROSS join every combination of everything so to speak
I'm not convinced I've helped you
Regards
Jim
Im not finding anything similar in the Posts so correct me if Im wrong...
Im real new to programing in Access (Been a while since I programed in anything). The question I have is.. How do you make letters increment?
It may sound weird but, I need to create unique numbers based on day and year. That part I can do. The last two Digits in the Number are two letters though ... AA through ZZ and I cant figure out how to get those to increment through all their values. i.e. AA,AB,AC,AD....ZY,ZZ.
Any ideas how to do this?
This will probably work...but I'm curious what happens when you run out of alphabet -
Function IncrementAlpha(strIn As String) As String
-
'Pass this function your two letter string
-
'Example myNewString = IncrementAlpha("ab")
-
'will return "ac"
-
-
Dim sAlphaBet As String
-
Dim sFirstLetter As String
-
Dim sSecondLetter As String
-
Dim X As Variant
-
Dim I As Long
-
sFirstLetter = Left(strIn, 1)
-
sSecondLetter = Right(strIn, 1)
-
sAlphaBet = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"
-
X = Split(sAlphaBet, ",")
-
-
If sSecondLetter = "z" Then
-
'loop to get next first letter
-
For I = I To UBound(X) - 1
-
If X(I) = sFirstLetter Then
-
sFirstLetter = X(I + 1)
-
sSecondLetter = "a"
-
Exit For
-
End If
-
Next I
-
Else
-
'loop to get the next second letter
-
For I = 0 To UBound(X) - 1
-
If X(I) = sSecondLetter Then
-
sSecondLetter = X(I + 1)
-
sFirstLetter = sFirstLetter
-
Exit For
-
End If
-
Next I
-
End If
-
IncrementAlpha = sFirstLetter & sSecondLetter
-
End Function
-
J
Im not finding anything similar in the Posts so correct me if Im wrong...
Im real new to programing in Access (Been a while since I programed in anything). The question I have is.. How do you make letters increment?
It may sound weird but, I need to create unique numbers based on day and year. That part I can do. The last two Digits in the Number are two letters though ... AA through ZZ and I cant figure out how to get those to increment through all their values. i.e. AA,AB,AC,AD....ZY,ZZ.
Any ideas how to do this?
Pass this Function 2-Letters and it will do the incrementing for you: - Public Function fIncrementLetters(strLastLetters As String)
-
'Check for exactly 2 Letters - (Upper or Lower Case)
-
If Len(strLastLetters) <> 2 Then Exit Function
-
If Asc(UCase$(Left$(strLastLetters, 1))) < 65 Or Asc(UCase$(Left$(strLastLetters, 1))) > 90 Then Exit Function
-
If Asc(UCase$(Right$(strLastLetters, 1))) < 65 Or Asc(UCase$(Right$(strLastLetters, 1))) > 90 Then Exit Function
-
-
If UCase$(Right$(strLastLetters, 1)) <> "Z" Then
-
fIncrementLetters = UCase$(Left$(strLastLetters, 1)) & Chr$(Asc(UCase$(Right$(strLastLetters, 1))) + 1)
-
Else
-
fIncrementLetters = Chr$(Asc(UCase$(Left$(strLastLetters, 1))) + 1) & "A"
-
End If
-
End Function
SAMPLE OUTPUT:
fIncrementLetters("lz") ==> "MA"
fIncrementLetters("AA") ==> "AB"
fIncrementLetters("Qg") ==> "QH"
fIncrementLetters("ZZ") ==> "[A"
...etc. NOTE: It does not check for the last possible Letter Combination, namely ZZ as clearly indicated in the last Sample Output. I'll leave this up to you but if you are stuck, please let me know.
Pass this Function 2-Letters and it will do the incrementing for you: - Public Function fIncrementLetters(strLastLetters As String)
-
'Check for exactly 2 Letters - (Upper or Lower Case)
-
If Len(strLastLetters) <> 2 Then Exit Function
-
If Asc(UCase$(Left$(strLastLetters, 1))) < 65 Or Asc(UCase$(Left$(strLastLetters, 1))) > 90 Then Exit Function
-
If Asc(UCase$(Right$(strLastLetters, 1))) < 65 Or Asc(UCase$(Right$(strLastLetters, 1))) > 90 Then Exit Function
-
-
If UCase$(Right$(strLastLetters, 1)) <> "Z" Then
-
fIncrementLetters = UCase$(Left$(strLastLetters, 1)) & Chr$(Asc(UCase$(Right$(strLastLetters, 1))) + 1)
-
Else
-
fIncrementLetters = Chr$(Asc(UCase$(Left$(strLastLetters, 1))) + 1) & "A"
-
End If
-
End Function
SAMPLE OUTPUT:
fIncrementLetters("lz") ==> "MA"
fIncrementLetters("AA") ==> "AB"
fIncrementLetters("Qg") ==> "QH"
fIncrementLetters("ZZ") ==> "[A"
...etc. NOTE: It does not check for the last possible Letter Combination, namely ZZ as clearly indicated in the last Sample Output. I'll leave this up to you but if you are stuck, please let me know.
Mine is prettier Dez :o)
Thanks to both of you for your help. I'll try them both and see which one works better :)
As for checking for the last possible combination "ZZ", If I ever get 676 items in in one day....My job has gotten way too complex and I won't get them all checked in anyway, then it will be the next day and the counter starts over. :) So I don't think ZZ will ever get used
Mine is prettier Dez :o)
Never said my code was pretty, only functional. (LOL).
They both work... So Thanks to all... When it is ZZ and tries to increment it gets an error... But again no big deal cause thats way more than Ill ever need :)
They both work... So Thanks to all... When it is ZZ and tries to increment it gets an error... But again no big deal cause thats way more than Ill ever need :)
No provision was made for this contingency, as indicated by the notation on Post #4. You can simpy exit the Function if this condition exists via: - If UCase$(strLastLetters) = "ZZ" Then Exit Function
Hi, everyone.
Just another approach.
The value may be stored in table as number and converted to base 26 numeration system (digits A-Z) number when needed. -
Public Function GetAZNumber(ByVal intInput As Integer) As String
-
-
GetAZNumber = Chr(Int(intInput / 26) + Asc("A")) & _
-
Chr(intInput Mod 26 + Asc("A"))
-
-
End Function
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: trickydicky |
last post by:
Does anyone know of an easy way to increment a string by one letter at
a time?
What I want to be able to do is set a variable with the value "A" and
then be able to use a For loop to make it...
|
by: Edward K. Ream |
last post by:
From the documentation for the string module at:
C:\Python23\Doc\Python-Docs-2.3.1\lib\module-string.html
letters: The concatenation of the strings lowercase and uppercase described
below....
|
by: John Velman |
last post by:
I've used perl for a lot of 'throw away' scripts; I like Python better in
principle, from reading about it, but it was always easier to just use
perl rather than learn python.
Now I'm writing a...
|
by: Michael |
last post by:
Hi,
I've got a string s, and i want to shift all the letters up by one, eg a->b,
b->c ........ z->a
In c++ i can do this quite simply with
if(C == 'z') C='a';
else C++;
but i can't work out...
|
by: Mothra |
last post by:
Here's what I'm trying to do (kill off old Unix logins):
---------------------
$i=0;
while (<$who>) {
chomp($_);
my @line = split(/\s+/, $_); # Split it into an array
next unless ($line...
|
by: brian |
last post by:
Hi, before coming to .NET, I utilized regular expressions mostly in JScript /
JavaScript and also in my favorite text editor: TextPad (www.textpad.com)
I don't know about JScript/JavaScript, but...
|
by: Antanas |
last post by:
The problem is that when AddID is used multiple times in the same
select statement, it returns the same value in all places. How could I
force function AddID to increment OBJECTID sequence?
Here...
|
by: JD via AccessMonster.com |
last post by:
I am trying to create a field where the primary key field will produce JDP-
001; where the three letters come from the first name, middle intial and
last name of my table. I want to auto increment...
|
by: subramanian100in |
last post by:
The following portion is from c-faq.com - comp.lang.c FAQ list ·
Question 6.13
int a1 = {0, 1, 2};
int a2 = {{3, 4, 5}, {6, 7, 8}};
int *ip; /* pointer to int */
int (*ap); /* pointer to...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |