jt463
IS-IT--Management
- Nov 23, 2005
- 134
I have records in one database that are formatted like so:
Subdivision-01
Subdivision-21
etc...
In another database, they are formatted as two separate records:
sub 001
sub 021
I am working to bring the two together by adding two fields to our original database so that we can tie the two together.
However, I am trying to figure out a way I can do an insert that will automatically add the leading zeros - IF NECESSARY. What I mean by that is that we could have a record that is: Subdivision-01 where I need to add 1 zero to make it '001', but then we could also have a record that is Subdivision-100 where I don't need to add any.
I would need the code to look at the record from the first database (example: Subdivision-01) and tell it to only examine the data to the right of the '-'. Then, it will need to determine if it is 3 characters in length, and if not - then it will need to add zeros to get the 3 character length. (Is this possible?!?) I will hard-code the proper correlating project name from the data left of the '-'.
In other words: Subdivision-01 should translate to 'sub' and '001'.
My second database is a 3 char fixed text length. The original database is simply a text field where the lot numbers are anywhere from 2 to 3 character lengths.
Any ideas would be greatly appreciated!
I am going to need to do this in two stages. I am going to write a public function which will look at my existing records and update them with the second database format. Then, I will write a private sub to make sure they are updated, going forward.
Subdivision-01
Subdivision-21
etc...
In another database, they are formatted as two separate records:
sub 001
sub 021
I am working to bring the two together by adding two fields to our original database so that we can tie the two together.
However, I am trying to figure out a way I can do an insert that will automatically add the leading zeros - IF NECESSARY. What I mean by that is that we could have a record that is: Subdivision-01 where I need to add 1 zero to make it '001', but then we could also have a record that is Subdivision-100 where I don't need to add any.
I would need the code to look at the record from the first database (example: Subdivision-01) and tell it to only examine the data to the right of the '-'. Then, it will need to determine if it is 3 characters in length, and if not - then it will need to add zeros to get the 3 character length. (Is this possible?!?) I will hard-code the proper correlating project name from the data left of the '-'.
In other words: Subdivision-01 should translate to 'sub' and '001'.
My second database is a 3 char fixed text length. The original database is simply a text field where the lot numbers are anywhere from 2 to 3 character lengths.
Any ideas would be greatly appreciated!
I am going to need to do this in two stages. I am going to write a public function which will look at my existing records and update them with the second database format. Then, I will write a private sub to make sure they are updated, going forward.