Ken
|
| Posted: 05/24/2004, 8:01 AM |
|
I have a Field where the user enters their Customer Code, located on an order form, When i hit submit at the bottom, how can i check to see if that customer code is in my database, to see if the record can be submitted, cuz if it not, i do not want the record submitted, Any help would be great, Thanks
ASP,MS ACCESS,CCS
Thank You
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 05/24/2004, 6:28 PM |
|
You can set the "Unique" property of that field to "Yes".
Otherwise you could use the On Validate event with the CCDLookup function.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Ken
|
| Posted: 05/25/2004, 5:56 AM |
|
I need a field to validate, Whne i hit submit, if the value submitted is not on th elist, it will not proccess, How and Where do i do this, Thanks for all you help, Peter
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 05/25/2004, 11:26 AM |
|
I'm not sure if the "Unique" property is not sufficient in this case?
Do you need to validate one field against another? If so, then take a look at http://docs.codecharge.com/studio/html/ProgrammingTechn...Validation.html
You can use CCDLookup function to check if the field exists in the database, for example:
If CCDLookup("field_name","table_name","field_name=" & DBConnection1.ToSQL(Form1.TextBox1.Value , ccsText), DBConnection1) <> "" Then Form1.Errors.addError("This field is already in the database")
(this is untested code)
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Ken
|
| Posted: 05/25/2004, 12:19 PM |
|
I want to make sure the Customer Record is in the database, , Please help
|
|
|
 |
Tony Do
|
| Posted: 05/25/2004, 4:46 PM |
|
Hi Ken,
Say, you want to insert a record into Customer table and you want to check
to see if the customer with the same surname and firstnames is already in
the database. You can exend this further more with D.O.B and address
Table: customers
Field name to check: surname, firstnames
In the before insert event of your record form
<code>
Dim whereSQL
Dim SurnameStr, FirstnameStr
SurnameStr = DBConnection1.ToSQL(eventcaller.surname.value , ccsText)
FirstNameStr = DBConnection1.ToSQL(eventcaller.firstnames.value , ccsText)
whereSQL = "surname=" & SurnameStr & "'" & " AND firstnames=" & FirstnameStr
If cInt(CCDLookup("count(*)", "customers", whereSQL, DBConnection1 )) > 0
Then
EventCaller.InsertAllowed = false
EventCaller.Errors.Adderror("This customer is already the data base")
End If
</code>
|
|
|
 |
|