Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB - Change MaxLength from 4 to 5 1

Status
Not open for further replies.

nu2it

IS-IT--Management
Aug 31, 2006
9
US
My disclaimer- I've been a hardware person my from the start of my IT career with very basic programing experience.
I've started with a company that has a web based project database. It looks like it was created in VB4. It has a CGI4VB script at the beginning that seems to setup the form
that is used to enter project info. I've seen this CGIVB4 script all over the internet.

What I need help with is - being able to add a letter after the first 4 original numbers of the project. I have VB6 and have made changes to the part of the job # I want to add a letter to. I then compile this and create a new jobbase.exe, insert it into the CGI-bin folder. I can indeed enter the additional letter but I receive a "This is not a valid job # error. I would prefer to not post it until I know someone would be interested in looking at it.

TIA

John
 
'This is not a valid job' must be in the code somewhere. I expect some code is checking for length. If you find the 'This is not a valid job' text, it should be somewhere near.
 
Thanks for the reply.
Here's a portion of the script that defines the MaxLenght of the fields. I pulled some data out of the middle. The jn1 (New job) and jne1 (Existing job) are the fields I'm attempting to increase to 5 characters.
Option Explicit
Sub NewForm()
Send "<html><head><title>New Project Information</title></head>"
Send "<body bgcolor=000000 background=/cgi-bin/pkcegrey.gif><BR>"
Send "<center><table border=0 width=750 cellpadding=4 background=images/JE-Background.gif><FORM ACTION=/cgi-bin/jobbase.exe METHOD=post><INPUT type=hidden name=do maxlength=1 size=1 value=1><tr><td width=750>&nbsp;</td></tr>"
Send "<tr><td>&nbsp;<img src=/images/spacer.gif width=122 height=1><INPUT name=jn1 maxlength=5 size=6>&nbsp;&nbsp;&nbsp;<INPUT name=jn2 maxlength=2 size=3>&nbsp;&nbsp;&nbsp;<INPUT name=jn3 maxlength=3 size=4><img src=/images/spacer.gif width=266 height=1><INPUT name=d1 maxlength=2 size=2 value=" & Month(Date) & ">&nbsp;&nbsp;&nbsp;<INPUT name=d2 maxlength=2 size=2 value=" & Day(Date) & ">&nbsp;&nbsp;&nbsp;<INPUT name=d3 maxlength=2 size=2 value= " & Mid(Year(Date), 3) & "></td></tr>"
Send "<tr><td>&nbsp;<img src=/images/spacer.gif width=101 height=1><INPUT name=proj maxlength=75 size=40></td></tr>"
Send "<tr><td>&nbsp;<img src=/images/spacer.gif width=50 height=1><INPUT name=client maxlength=75 size=40><img src=/images/spacer.gif width=86 height=1><INPUT name=mapsco1 maxlength=4 size=5>&nbsp;&nbsp;&nbsp;<INPUT name=mapsco2 maxlength=1 size=2>&nbsp;&nbsp;&nbsp;&nbsp<img src=/images/spacer.gif width=35 height=1><img src=/images/spacer.gif width=35 height=1><INPUT name=mapsco3 type=radio Value=D Checked></td></tr>"

BigOptions
Send "</select></td></tr>"
Send "<tr><td width=750><img src=/images/spacer.gif width=152 height=1><INPUT name=jne1 maxlength=5 size=6>&nbsp;&nbsp;&nbsp;<INPUT name=jne2 maxlength=2 size=3>&nbsp;&nbsp;&nbsp;<INPUT name=jne3 maxlength=3 size=4></b></font>"
Send "<img src=/images/spacer.gif width=295 height=1><INPUT type=submit value=Submit><INPUT type=reset value=Reset></Form></tr></table></center><BR></body></html>"
End Sub
Sub LookUpJob()
Dim job As String
Dim i
job = GetCgiValue("jne1") & "-" & GetCgiValue("jne2") & "." & GetCgiValue("jne3")
If Len(job) <> 11 Then Send "<body bgcolor=000000><SCRIPT LANGUAGE=JavaScript>function goHist(a){history.go(a);}</script><font size=4 face=arial color=FF0000><Center><b>You have entered an invalid Job Number! Please go back and enter the information correctly.</B><BR><FORM METHOD=post><INPUT TYPE=button VALUE=" & Chr(34) & "Go back and fix the problem" & Chr(34) & "onClick=goHist(-1)></form></center>": GoTo Done

rs.MoveLast: rs.MoveFirst
For i = 1 To rs.RecordCount
If job = rs!jobno Then GoTo FillForm
rs.MoveNext
Next i
GoTo FixError
FillForm:
Send "<html><head><title>New Project Information</title></head>" '<BASE TARGET=DATA>"
Send "<body bgcolor=000000 background=/cgi-bin/pkcegrey.gif><BR>"
Send "<center><table border=0 width=750 cellpadding=4 background=images/JE-Background.gif><FORM ACTION=/cgi-bin/jobbase.exe METHOD=post><INPUT type=hidden name=do maxlength=1 size=1 value=3><tr><td width=750>&nbsp;</td></tr>"
Send "<tr><td>&nbsp;<img src=/images/spacer.gif width=122 height=1><INPUT name=jn1 maxlength=5 size=6 value=" & Mid(rs!jobno, 1, 6) & ">&nbsp;&nbsp;&nbsp;<INPUT name=jn2 maxlength=2 size=3 value=" & Mid(rs!jobno, 6, 2) & ">&nbsp;&nbsp;&nbsp;<INPUT name=jn3 maxlength=3 size=4 value=" & Mid(rs!jobno, 9, 3) & "><img src=/images/spacer.gif width=266 height=1><INPUT name=d1 maxlength=2 size=2 value=" & Month(rs!Date) & ">&nbsp;&nbsp;&nbsp;<INPUT name=d2 maxlength=2 size=2 value=" & Day(rs!Date) & ">&nbsp;&nbsp;&nbsp;<INPUT name=d3 maxlength=2 size=2 value= " & Mid(Year(rs!Date), 3) & "></td></tr>"
Send "<tr><td>&nbsp;<img src=/images/spacer.gif width=101 height=1><INPUT name=proj maxlength=75 size=60 value=" & Chr(39) & Mid(rs!projectname, 1, 75) & Chr(39) & "></td></tr>"
Send "<tr><td>&nbsp;<img src=/images/spacer.gif width=50 height=1><INPUT name=client maxlength=75 size=40 value=" & Chr(39) & Mid(rs!client, 1, 75) & Chr(39) & "><img src=/images/spacer.gif width=82 height=1>"
 
job = GetCgiValue("jne1") & "-" & GetCgiValue("jne2") & "." & GetCgiValue("jne3")
is that 5 + '-' + 2 + '.' +3 ?

So If Len(job) <> 11 should be <> 12

?

 
Changed to 12 at two locations and had the same result
"You have entered an INVALID JOB NUMBER! Please go back and fix the error" grrrrr. This has been driving me crazy for weeks. It doesn't seem that difficult to figure out but I just can't find it.

Would the size=6 make any difference. It was originally at 5
I've tried it without success.

 
Can you put a breakpoint in where the value of job is calculated and see what is going on? or maybe messages boxes with the values returned by getcgivalue and the resulting value of job.
That should show you where the problem is.
 
Would I insert the breakpoint next to the job = GetCGIValue
or next to the If Len(job) <> 12 statement.

Thanks again for your patience.
 
Ok, inserted the breakpoints but I'm not sure what I'm looking at or looking for.
I removed the breakpoints and stepped thru using the F8 key
It never got to module2 that has the CGIValues.
Would you be willing to look at the whole thing if I could get it to you jwalthers@pkce.com
 
I've can now enter the a new project code with an additonal number but I do get an error when I attempt to do a Lookup after it has been entered. I haven't figured out how to enter a letter, but for the moment, the additional digit will work.
Your tips have come in very handy, though I'm not sure what to do with the immediate window.
The thing that has made a difference was in the Job Check

If (Len(temp) = 5) And (temp > 1) And (temp < 10000) Then

I increased (temp < 10000) to 90000. I realized all my project codes would be in the 20000+ range with the additional digit.
Now I'm trying to figure how I can do a Lookupjob and not get the same error.
Any suggestions would be greatly appreciated.
And again, Thanks for your assistance.

JW

 
Okay, fixed my maxlength issue and it ended up being a litle more then what I had previously posted.
I changed the "If Len(job) <> 12" to "If Len(job) < 11"
Below is an additional change I made in module 1. I chaged the value = 4 to >=4

Dim temp
temp = GetCgiValue("do")

If temp = 0 Then NewForm: GoTo Done
If temp = 1 And Len(GetCgiValue("jne1")) >= 4 Then LookUpJob: GoTo Done
If temp = 3 And Len(GetCgiValue("jne1")) >= 4 Then LookUpJob: GoTo Done
If temp = 1 Then JobCheck: GoTo Done
If temp = 2 Then JobAdd: GoTo Done
If temp = 3 Then SaveChanges: GoTo Done 'User has modified a job and is requesting access to save changes
Send "<body bgcolor=000000><font size=4 face=arial color=FFFFFF><Center><b>Job-Base Editor<BR><font size=2 face=arial color=FFFFFF>(C)2003 Pacheco Koch Consulting Engineers</B></center>"
GoTo Done

This allows job codes to have 4 and 5 numbers in the jn1 and jne1 fields. Now what I'm struggling with is this
I need to be able to enter a letter in place of the 5th number in the jn1 and jne1 field. At the same time I still need to be able to pull-up a job or project number that have only 4 numbers.
TIA for any assistance.

 
You are struggling aren't you. I take it you are doing this very much part time?
 
This is something that I have to do during my spare time.
Spare time is a rare thing for me.

 
Reviewing what I've done so far, can you tell me if I on the right track or painting myself into a corner.
I've been reading as many posts as I can today about entering alphanumeric text but cannot find an answer.

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top