aegregory
Posts: 7
|
| Posted: 01/06/2006, 2:19 PM |
|
CCS2, ASP, javascript
I borrowed some code from the Popup & Smart Lookup example. My application has a link to a popup window where users search for a customer. After selecting the customer from the result set, the value is passed back to a textbox on the main form (funnel.asp) and the popup window closes. When the users submit the main form, the validation kicks in but it is not working properly. For example, if I search on 'Berg', the result set includes 'Berg' and 'MZ Berger'. If I select Berg and try to submit the form, it tells me 'Too many customers found'. If I search for a customer name that isn't duplicated in any way, the validation works fine. Below is the code that I'm using. I thought changing "customer_name like " to "customer_name = " would fix the problem, but it just resulted in errors. I tried removing the validation completely and got more errors. I'm very much a novice at this and actually applying the CCS Example to my application was a major milestone for me.
Any help or suggestions would be greatly appreciated!
-----------------------------------------------------------------------
Function funnel_OnValidate() 'funnel_OnValidate @48-BAF7E421
'Custom Code @98-73254650
' -------------------------
Dim CustCount
Dim search_name
search_name = trim(funnel.customer_id.Value)
If search_name <> "" Then
search_name = replace(search_name," ","% ")
if instr(search_name,"%") = 0 Then
search_name = "%"&search_name&"%"
Else
search_name = search_name&"%"
End If
If instr(search_name,"'") >0 Then _
search_name = replace(search_name,"'","''")
CustCount = CCDLookUp("COUNT(*)", "customers", "customer_name like "&DBConnection1.ToSQL(search_name,ccsText), DBConnection1)
if CustCount > 1 Then
funnel.Errors.addError("Too many customers found.")
End if
If CustCount = 0 Then
funnel.Errors.addError("Customer not found.")
End if
If CustCount = 1 Then
funnel.customer_id.Value = _
CCDLookUp("customer_id", "customers", "customer_name like "&DBConnection1.ToSQL(search_name,ccsText), DBConnection1)
End if
End if
' -------------------------
'End Custom Code
|
 |
 |
|