Urgent help needed with VB code! (1 Viewer)

edtab

Registered User.
Local time
Today, 14:47
Joined
Mar 30, 2002
Messages
257
I have an application that tracks maintenance contracts including their renewals.

The contract no. field is 6 bytes long.
Each time a contract is renewed, I need to increment the suffix by "1". For example, the contract no. "1236" will be renewed as "1236-1" and a contract no. with a "-1" will be renewed as "-2" and so forth and so on. Please keep in mind that I could be starting with a contract no. with or without the suffix already in.

Could really use some help on the code.

edtab
 

doulostheou

Registered User.
Local time
Today, 08:47
Joined
Feb 8, 2002
Messages
314
I'm assuming your field holding the contract number is named ContractNum.

Dim NewSuf as string
Dim ConCount as Integer
Dim ConLeft as String
Dim ConRight as Integer

ConCount = Len(ContractNum) 'Counts the number of characters in the contract number
ConLeft = Left(Contract,4) 'Cuts off the first four characters
If ConCount = 4 Then
ContractNum = ConLeft & "-1"
Else
ConRight = Right(Contract,1) 'Cuts off the last character
ContractNum = ConLeft & "-" & ConRight + 1
End If

I didn't have time to test this. I've never tested the left or right functions with integers, but I'm assuming it works.
 

edtab

Registered User.
Local time
Today, 14:47
Joined
Mar 30, 2002
Messages
257
Wow, thanks for the quick response.

I will try the code and let you know of the result.

After looking at the logic, it appears that it will work fine.

Thanks once more!

edtab
 

RichMorrison

Registered User.
Local time
Today, 08:47
Joined
Apr 24, 2002
Messages
588
Or create 2 fields, ContractNum and RenewalNum. When you create a new contract the renewal num is zero.

When you renew a contract, increment RenewalNum by +1.

RichM
 

Users who are viewing this thread

Top Bottom