...

View Full Version : IF form field = record set? help?!



bean262
07-26-2004, 08:47 PM
I have a form that requires users to select a date from the drop down menu. If a date is not select, error message appears. I want the page to return a different error if a date selected is already in the database. Here's my code thus far:



dim Err, rsCKDupDates
Set rsCKDupDates = CreateObject("ADODB.Recordset")
Sql ="Select distinct Attend_Date as DupDates From table WHERE table.PEOPLE_CODE_ID= 'P" & Session("peopleID") & " '"
rsCKDupDates.Open sql, conn

Err = False
'force user to choose a goal
IF Request.Form("Date") = "BAD" OR (IsNull(Request.Form("place"))) or (Request.Form("Date") = rsCKDupDates("DupDates")) then
Response.write "<center><strong class='error'>You must enter the date and the name of the place you wish to record, in order to continue.</strong></center><br>"
end if



According to this code however, if it worked the way I want it to, it would return the SAME error message for all three "IF" scenarios.

Instead, I would rather have it return a second/separate error message if the date in the form was already present in the database.

Any and all advice is greatly appreciated!

--Steve

A1ien51
07-27-2004, 04:51 AM
you if else statements instead of having them all in one line....

bean262
07-27-2004, 01:47 PM
ok, i tried it...if I did it right. The page loads, but it doesn't return the error if I select a date from the drop-down that is already in the database. Here's my code:



Err = False
'user choose a date
IF Request.Form("Date") = "BAD" OR (IsNull(Request.Form("place"))) then
Response.write "<center><strong class='error'>You must enter the date and the name of the place you wish to record, in order to continue.</strong></center><br>"

end if

if (Request.Form("Date") = rsCKDupDates("DupDates")) then
Response.write "<center><strong class='error'>You must select a different date.</strong></center><br>"

end if



Any other suggestions?

bean262
07-27-2004, 01:51 PM
I also tried an "if else" - but it doesn't like the two "then" statements, i guess.

here is the code i have for that:



Err = False
'user choose a date
IF Request.Form("Date") = "BAD" OR (IsNull(Request.Form("place"))) then
Response.write "<center><strong class='error'>You must enter the date and the name of the place you wish to record, in order to continue.</strong></center><br>"

else if (Request.Form("Date") = rsCKDupDates("DupDates")) then
Response.write "<center><strong class='error'>You must select a different date.</strong></center><br>"

end if



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum