473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Generating an alpha-numeric key

33
We are trying to create a filing system at work so that when a new file folder is created a form is filled out via MS Access and all the files will be tracked through these entries. Hes my problem I need a file number created for each file that is created via the form in Access. The file number needs to be alphanumeric (ex. HL01-01a) with the first 2 letters being an abbreviation of the value selected in the property field (hope that makes sense).

4 fields will combine to create the file number (in this order):
Property: HL
File type: 01
Main file name: 01
Sub file name: a

The problem I am having is having the values that make up the file number change depending on what value is selected from the property field and the file type field. And having the Main file and sub file numbers auto roll.

Thanks to ADezii I have it so the file number field gets populated with the right values in the proper order so thats awesome. But it needs to be in the format stated above if its at all possible. Below is the code I have right now.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. Dim strFileNum As String
  3.  
  4. If Me.NewRecord Then        'is this a New Record
  5.   'All 4 Fields must contain values in order to generate FILE NUMBER
  6.   If Not IsNull(Me![PROPERTY]) And Not IsNull(Me![FILE TYPE]) And Not IsNull(Me![MAIN FILE NAME]) And Not IsNull(Me![SUB FILES NAME]) Then
  7.     strFileNum = Me![PROPERTY] & Me![FILE TYPE] & "-" & Me![MAIN FILE NAME] & Me![SUB FILES NAME]      'concatenate the 4 entries
  8.     Dim intLastID As Integer, strLastFileNum As String, strLastProperty As   String, strLastFileType As String
  9.     Dim strLastMainFileName As String, strLastSubFileName As String
  10.     intLastID = DLast("[File ID]", "ALL")
  11.     strLastFileNum = DLookup("[FILE NUMBER]", "ALL", "[File ID]=" & intLastID)
  12.     strLastProperty = Left$(strLastFileNum, 2)
  13.     strLastFileType = Mid$(strLastFileNum, 3, 2)
  14.     strLastMainFileName = Mid$(strLastFileNum, 6, 2)
  15.     strLastSubFileName = Right$(strLastFileNum, 1)        'future processing here
  16.     'Write this value to the FILE NUMBER Field (Temporary)
  17.     Me![FILE NUMBER] = strFileNum
  18.   Else     '1 or more Fields contain no value - cannot do!
  19.     Cancel = True
  20.   End If
  21. Else
  22.   End If
  23. End Sub
  24.  
I hope I made this clear enough and if anyone can help in anyway I would really appreciate it.
Aug 7 '07 #1
8 2055
JKing
1,206 Expert 1GB
Please remember to provide a meaningful Title for any threads started (Please Use Appropriate Titles for New Threads!).

This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

MODERATOR.
Aug 7 '07 #2
ggtw
33
Ok sorry I appologize
Aug 7 '07 #3
ggtw
33
Any Help? I'm really stuck
Aug 8 '07 #4
JKing
1,206 Expert 1GB
With your current code I see you are concatenating the 4 pieces into one string. What format are you currently producing and how exactly do you need it changed? Are any pieces currently correct?
Aug 8 '07 #5
ggtw
33
With your current code I see you are concatenating the 4 pieces into one string. What format are you currently producing and how exactly do you need it changed? Are any pieces currently correct?
Well right now the values selected/entered are what is being put into teh FILE NUMBER field.
ex. HIGHLAKEPERMITWOLFDENRESOURCESINCWOLFDENRESOURCESI NC

So the problem I am having is I need it to go from that to HL(for High Lake) 01(for Permit) -01(Main File name) a(sub file name)

I should also add I am getting an error message saying invalid use of null for the
"strLastFileNum = DLookup("[FILE NUMBER]", "ALL", "[ID]=" & intLastID)" line.

Thank you for your response
Aug 8 '07 #6
JKing
1,206 Expert 1GB
I guess the big question is now whether you have abbreviations/codes stored somewhere that you can easily lookup to put the string together? Otherwise this could be a very difficult task.
Aug 8 '07 #7
ggtw
33
I guess the big question is now whether you have abbreviations/codes stored somewhere that you can easily lookup to put the string together? Otherwise this could be a very difficult task.
Well no i would need to create them....Thats where i'm having problems would i do each one individually like Permit= 01 Report= 02 etc or what would be the best way?
Aug 8 '07 #8
ggtw
33
Well no i would need to create them....Thats where i'm having problems would i do each one individually like Permit= 01 Report= 02 etc or what would be the best way? All the values for the File type field and property field are in combo boxes. Does this answer yoru question???
Aug 8 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Dan Gass | last post by:
The difflib.py module and the diff.py tools script in Python 2.4 alpha 3 now support generating side by side (with intra line differences) in HTML format. I have found this useful for performing...
1
by: Torben Hoffmann | last post by:
Hi, I have searched high and low for an answer to this, but I have not been able to find it. I have found tools (such as Batik) to generate a gif|jpeg|png from a SVG file, but I would also...
9
by: Marek Kurowski | last post by:
Yo! What mean when program is ALPHA or BETA version? I suppose it is not release version of program, but I don't know what it exactly mean. What it mean in your opinion? Marek Kurowski
3
by: instruo | last post by:
I'm using the System.Drawing.Bitmap class for loading a 32-bit bmp file which includes an alpha channel. The problem is, when it gets loaded (just using the Bitmap(string filename) constructor),...
0
by: Ken Fine | last post by:
Apologies if this is not the right place for this question. I'm curious what method people use in practice to translate database data into XML that can be consumed by XML-hungry controls. I'm...
5
by: k.i.n.g. | last post by:
Hi, I have a csv file which in taken as the input file for adding users in my linux mail server with the format userid,fullname,passwword,dateofbith Now I have to write a script to generate...
6
by: tommaso.gastaldi | last post by:
In a previous post I have been asking about a way to test Alpha Transparency. Bob and Michael have kindly provided some ideas. Here I would like to share the function I have prepared, for the...
14
by: avanti | last post by:
Hi, I need to generate random alphanumeric password strings for the users in my application using Javascript. Are there any links that will have pointers on the same? Thanks, Avanti
3
by: Gernot Frisch | last post by:
Hi, I have this code that blends 2 pixels, but it's not really fast. Can someone help me speeding it up? #define GETR(a) (unsigned char)(((((a)>>11)&31)*255)/31) #define GETG(a) (unsigned...
3
by: Sebastian Bassi | last post by:
Hello, What are people using these days to generate HTML? I still use HTMLgen, but I want to know if there are new options. I don't want/need a web-framework a la Zope, just want to produce...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
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,...
0
Oralloy
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.