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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error?

Status
Not open for further replies.

alpha33

IS-IT--Management
Apr 2, 2006
8
US
I am using the following code for collecting a date from a form and then inserting it in SQL. Most of the users are able to use it without any problem, but recently some users have received the following error upon submitting the form:

Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'MonthName'
/Page.asp, line 76


The problamatic lines of the code seem to be:
Code:
dim CED
			CED = "1/" & MonthName(cint(Request.Form("cmbCCM"))+1) & "/" & Request.Form("cmbTxtCCY")
			if Cdate(CED) < date()+2 then
				ErrMsg = ErrMsg & "Enter a valid expiration date.<br>"
Is there a suntax error or some other error in this code? Thanks.

 
Not a syntax error, an invalid argument to the MonthName() method... it should be a number in the range of 1 to 12.


Perhaps there is some situation where cint(Request.Form("cmbCCM"))+1 produces a value outside of this range?
 
make sure that you have the value for
Request.Form("cmbCCM")

i mean make sure that it is not empty...

-DNG
 
Thanks for your posts. Request.Form("cmbCCM") is not empty (value comes from a dropdown menu). I think it's the logic that is wrong. When the month is December,
MonthName(cint(Request.Form("cmbCCM"))+1)
fails because MonthName(13) is invalid.
 
then do this...

if cint(Request.Form("cmbCCM")<12 then
MonthName(cint(Request.Form("cmbCCM"))+1)
end if

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top