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

Clear screen entries if condition exists 1

Status
Not open for further replies.

acewilli

IS-IT--Management
Apr 11, 2003
98
US
Hello,

I need to clear the entries on the screen if a certain condition exists so that it never is updated in the database. Below is my update function and is where I am trying to make this happen. I need to make sure that the user doesn't use more than 10 points or less than 10 points such as a negative number. I need to reset the screen after the Update button is pressed but before anything is actually updated in the database. Any help is greatly appreciated.

Code:
If Request.Form("submit") = "Update" Then
 While not rsStatus.eof
   If rsStatus("npoints") > "10" Then
[COLOR=red]'need to clear entries here based on condition above
'and refresh the screen[/color]
   elseif rsStatus("npoints") < "10" Then
[COLOR=red]'need to clear entries here based on condition above     
'and refresh the screen[/color]
   else
   end if
'code continues here

Thank you in advance,

acewilli
 
I need to make sure that the user doesn't use more than 10 points or less than 10 points such as a negative number.

Not sure what you're saying here; but do you mean betwen 0 and 10, anything outside this range "clears" the entries?
 
I need to use from 0 to 10. I can't have anything over 10 or less than 0 which would be a negative number. Thank you for correcting me. I never get answers because I make mistakes when typing my questions. :) I appreciate the catch. Hope you can help me.

Thanks again,

acewilli
 
If the data is already in your recordset (rsStatus), wouldn't that indicate that it is already in your database?

I would suggest that you do that validation before you send any updates to the database.
1) Make sure an entry is between 0-10 (If Request.Form("whatever") >= 0 AND ... <= 10)
2) Pull back the users current amount of points they have assigned
3) now check to make sure current points + points from form is <= 10
4) with both conditions passed aboved, now is the time to do your updates

So something like:
Code:
Dim ptoa
ptoa = Request.Form("pointsToAssign")
If ptoa >= 0 And ptoa <= 10 Then
   Dim rsPoints
   'pull already assigned points into rsPoints from DB
   If rsPoints("pointsAssigned") + ptoa <= 10 Then
      'do your update statement
   Else
      Response.Write "Tha would exceed the number of points your allowed to assign"
   End if
Else
   Response.Write "You can only assign between 0 and 10 points"
End If

'display the form here.

 
I will try this. I think my biggest problem is that I calculate the yearly points as well as the monthly points with this so I'll need to be careful how I do this so that it doesn't use the points over 10 or under 0 to calculate into the monthly or yearly points. I'll let you know how it goes soon. Thank you for replying.

acewilli
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top