Dorin
Posts: 50
|
Posted: 09/30/2009, 11:58 PM |
|
Hello,
On a record form I have to make a simple validation against duplicate records before insert. So I put the bellow code on On Validate event:
Dim TPMConn
Dim Place
Dim Building
Set TPMConn = New clsDBconnection1
TPMConn.Open
Place = CCDLookUp("place", "_transactions", "i_id=" & DBConnection1.ToSQL(CCGetParam("id",""), ccsInteger) , DBConnection1)
Building = DBConnection1.ToSQL(TransactionsDetailsRec.i_building.Value,ccsinteger)
If (CCDLookUp("COUNT(*)", "view_buildings", "Building = " & Building AND "Place = " & "'" & Place & "'" , DBConnection1)) > 0 then
TransactionsDetailsRec.Errors.addError("Error: This building is ocupied!")
End If
'TPMConn.Close
'Set TPMConn = Nothing
This event give, for example: Type mismatch: '[string: "Building = 4"]' . (4 cames from a record form list box which has the bound column declared as integer.)
Strange is that both WHERE parameters works separately without any error. Only when I try to combine them with the AND operator I get the above error.
I use SQL database. The Building field is integer. The Place is varchar.
Any help will be greatly appreciate.
Thanks
|
|
|
mrachow
Posts: 509
|
Posted: 10/01/2009, 11:50 PM |
|
& Building & " AND " & "Place ...
or
& Building & " AND Place ...
_________________
Best regards,
Michael |
|
|
Dorin
Posts: 50
|
Posted: 10/02/2009, 3:49 AM |
|
Many thanks. It works.
Best regards,
Dorin
|
|
|
|