DataEnvironment and check If record Exist??

Balshe
Balshe used Ask the Experts™
on
I try to check if a record exists before adding new Record
and after the find Line i get this error:

" Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."

the command Properties:
CommandType=AdcmdTable
CurserLoaction=aduseserver
CursorType=adopenKeyset
LockType=adlLockOptimistic

What is wrong?????
 

With DataEnvironment1.rsCmdSchema
If Not .BOF Then .MoveFirst
    .Find "[Schema] ='" & Trim(txtSchema) & "'" & "   and      [Stage_id]=" & CmbStage.ItemData(CmbStage.ListIndex), , adSearchForward
   
    If Not .EOF Then
        MsgBox "Record Already Exists" & vbCrLf & vbCrLf & "Pls Write New Schema Name Or Stage"
        PutFocus txtSchema
        Exit Sub
    End If
            .AddNew
            !Schema = Trim(txtSchema)
            !stage_id = Val(CmbStage.ItemData(CmbStage.ListIndex))
           .Update
           RsChanged = True
End With
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
The Find method accepts only one criteria.
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
Have a look at Filter (it accepts more then one criteria).

Author

Commented:
can u tell me how would it look like?

i would be greatful
thank u

Author

Commented:
i mean if u could write  a code helping me to understand how??????
Senior .Net Consultant
Top Expert 2016
Commented:
simply replace
   .Find "[Schema] ='" & Trim(txtSchema) & "'" & "   and      [Stage_id]=" & CmbStage.ItemData(CmbStage.ListIndex), , adSearchForward

With
   .Filter = "[Schema] ='" & Trim(txtSchema) & "'" & "   and      [Stage_id]=" & CmbStage.ItemData(CmbStage.ListIndex)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial