Hi All,
I've got a relatively simple problem but my VB still isn't up to snuff.
I would like to create a Cargo Code using cgo-0708-001 where cgo is just a descriptive string, 0708 is the current month and year, and 001 is incremented with each new record unless the month changes; In which case the number would return to 001.
I can do it in deisel or lisp but my VB is still a little weak. With out error traps, variable definitions, or record sets, The Algorithm would be something like this:
The problem I'm having is that the concantenation involves a string, a date converted to a string, and a number converted to a string. While I'm read many example on this site, I'm still having a little trouble getting up to speed with VB syntax.
The reason I'm using this configuration as a code is because a cargo is not an entity that you can really identify with except for the date it entered the database and it becomes redundant very quickly. I would like to eventually purge any cargo records that are more than 3 months old. The code should make it easy to accomplish that.
If there are string tutorials that someone can recommend that would be great.
Thank for any assistance.
Cheers!!
I've got a relatively simple problem but my VB still isn't up to snuff.
I would like to create a Cargo Code using cgo-0708-001 where cgo is just a descriptive string, 0708 is the current month and year, and 001 is incremented with each new record unless the month changes; In which case the number would return to 001.
I can do it in deisel or lisp but my VB is still a little weak. With out error traps, variable definitions, or record sets, The Algorithm would be something like this:
Code:
1. Find last strCargoCode
2. Isolate the last 3 char of the code assign it to LastCode
3. Isolate 2 char month from last strCargoCode assign it to Month1
4. Isolate 2 char month from current date assign it to Month2 as string
5. If Month1 not equal Month2
6. Then NEWstrCargoCode = concant "cgo-" & "(current)MMYY" & "-" & "001"
7. Else NEWstrCargoCode = concant "cgo-" & "(current)MMYY" & "-" & "(LastCode+1)"
8. End If
9. Me.strCargoCode = NEWstrCargoCode
The problem I'm having is that the concantenation involves a string, a date converted to a string, and a number converted to a string. While I'm read many example on this site, I'm still having a little trouble getting up to speed with VB syntax.
The reason I'm using this configuration as a code is because a cargo is not an entity that you can really identify with except for the date it entered the database and it becomes redundant very quickly. I would like to eventually purge any cargo records that are more than 3 months old. The code should make it easy to accomplish that.
If there are string tutorials that someone can recommend that would be great.
Thank for any assistance.
Cheers!!