CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 form validation question

Print topic Send  topic

Author Message
charles
Posted: 06/05/2005, 9:20 AM

I have a record form based on a payroll table with following compound primary keys:employee_no and period_id.
I want to prevent the user from entering employee no twice in the same pay period.I can do this on the database but will like to accomplish this on the form.
I know i have to use CCDlookup but i dont know how to actually code this.
I need help.
Thanks
charles
smalloy

Posts: 107
Posted: 06/06/2005, 8:34 AM

The object is to test the database for employee_no with a same Period ID. If you find one add a error to stop the Insert (or Update) and notify the user. Here is what I propose:

Dim intEmp_no  
Dim intPeriod_id  
Dom intMatch  
  
intEmp_no = Record_or_Grid.textBoxName.Value  
intPeriod_id = Record_or_Grid.textBoxName.Value  
  
'Test for the employee in the same period  
intMatch = CCDLookUp("employee_no", "tableName", "employee_no = " & intEmp_no & " AND period_id = " & intPeriod_id, dbDataConnection)  
  
If Len(intMatch) > 0 Then ' there is one, add the error  
     Record_or_Grid.Errors.AddError "You may not add an employee twice in the same payperiod."  
End If

I hope this helps!
_________________
Anything can be done, just give me time and money.
View profile  Send private message
charles
Posted: 06/12/2005, 9:03 PM

Thanks for help.Sorry i was'nt around hence the late response.
i tried the code as suggested but i got this error message.

Source: CCDLookUp function
Command Text: SELECT employee_no FROM payroll1 WHERE employee_no=to22 AND period_id=1
Error description: No value given for one or more required parameters. (Microsoft JET Database Engine)

This shows that the lookup function did work so i can't understand this error mesage.
Please what can i do to resolve this?
Thanks for your usual thankness
peterr


Posts: 5971
Posted: 06/12/2005, 11:38 PM

The error message shows the SQL command that failed. The part "employee_no=to22" doesn't look valid to me. You either need to use numeric values as employee_no, or you should enclose text values in quotes.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.