Click to See Complete Forum and Search --> : Changing hard code


Pat S
September 14th, 2001, 02:23 PM
I have an application that only accepts 7 digit ID numbers. I need it to accept 9 digits and 7 digits. The code is full of validation rules. I can get it to accept 9 by changing the 7s to 9s, but that doesn't help me. I need it to accept both. There are three areas in the code that I am hung up on.

qd!pSiteNumber = Left(cmbSite, 7)
Dim strSaveSiteNumber as String * 7
qd!PSaveSiteNumber = Left$(Trim(cmbSite.text),7)

Any suggestions would be GREATLY appreciated.
Pat

John G Duffy
September 14th, 2001, 05:24 PM
use a variable instead of a hard coded number.
Replace the 7 with something like intIDLen then define intIDLEN like DIM intIDLEN as Integer.
SOmeplace befopreprocessing, set intIDLEN to 7 or 9 depending on your needs at the time. The whole process looks something like this

Dim strSaveSiteNumber as string
Dim intIDLen as Integer

If somecondition then
intIDLen = 7
else
intIDLen = 9
End If
strSaveSiteNumber = mid$(strSaveSiteNumber, 1, intIDLen)
qd!pSiteNumber = Left(cmbSite, intIDLen)
qd!PSaveSiteNumber = Left$(Trim(cmbSite.Text), intIDLen)





John G