PC Review


Reply
Thread Tools Rate Thread

Auto increment by one letter

 
 
Cinquefoil22
Guest
Posts: n/a
 
      27th May 2010
Simple question, hope I can get an answer....
Ok, I have created a table and form for our company to keep track of incoming
inventory. Being that we work with metals, each piece that comes in is
assigned
a unique 3 letter value. We started with AAA. What I need to know is once I
enter the item we are receiving is there a way for it to automatically go to
the
next sequence of letters. Example, yesterday we received in. The last
series
of letters I used was BHV. So today, when I receive in, I want the product
to
automatically be assigned BHW and then BHX and so on. After I use BHZ my
next sequence would be BIA. Ultimately when I get to BZZ, my next sequence
would be CAA and so on....
Now, here is the thing, I am not code saavy, so if someone could explain to
me how exactly I would set this up and where I would put it and how I would
get it in my form, I would appriate it....
Do you think you can help me figure out how to do this?
Many Thanks!!!
P.S. Someone did try to help me and this was the code they gave me:
Public Function Encode(strCode As String) As String
Dim strAB As String, c1 As String, c2 As String, c3 As String
Dim p As Integer
strAB = "ABCDEFGHIJKLMNOPQRSTUVWXYZA"
c1 = Left$(strCode, 1) 'first letter
c2 = Mid$(strCode, 2, 1) 'middle letter
c3 = Right$(strCode, 1) 'right letter
' Increment last letter
p = InStr(strAB, c3)
c3 = Mid$(strAB, p + 1, 1)
If c3 = "A" Then
' Increment middle letter
p = InStr(strAB, c2)
c2 = Mid$(strAB, p + 1, 1)
If c2 = "A" Then
' Increment first letter
p = InStr(strAB, c1)
c1 = Mid$(strAB, p + 1, 1)
End If
End If
Encode = c1 & c2 & c3
End Function

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Increment by 1 Letter Cinquefoil22 Microsoft Access Form Coding 2 28th May 2010 01:37 AM
Auto Increment by 1 letter Cinquefoil22 Microsoft Access Form Coding 0 28th May 2010 12:01 AM
Auto Increment by 1 Letter Cinquefoil22 Microsoft Access Database Table Design 3 27th May 2010 10:51 PM
RE: Auto Increment by 1 Letter Dorian Microsoft Access Database Table Design 0 27th May 2010 09:08 PM
Increment/Increment letter in alphabetical order =?Utf-8?B?TmVpbCBHb2xkd2Fzc2Vy?= Microsoft Excel Programming 3 25th Jan 2006 09:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:38 PM.