Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IF form field = record set? help?!

    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:

    Code:
    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

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    you if else statements instead of having them all in one line....
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New Coder
    Join Date
    Aug 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    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?

  • #4
    New Coder
    Join Date
    Aug 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    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>"
    	
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •