nfergusn

Difficulty with Query filter WhereClause using different fields

Discussion created by nfergusn on Jul 22, 2010
Latest reply on Jul 22, 2010 by nfergusn
I'm trying to create a query filter in order to guarantee that a user doesn't use the same value twice but am having difficulty creating a WhereClause that evaluates two different fields. I'm able to get it to work using one field, but when I add the second clause I get the following compile error:

Type-declaration character does not match declared data type.

I would appreciate any ideas as to how to fix this error, or any suggestions as to how I could accomplish the same task a different way.

Thanks!


Public Sub DuplicateEntry()

Dim pMxDoc As IMxDocument
Dim pMap As IMap
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap
Dim pFLayer As IFeatureLayer
Set pFLayer = pMap.Layer(0)
Dim pFClass As IFeatureClass
Set pFClass = pFLayer.FeatureClass

   
' query filter to test to see if the input value already exists
Dim pQf As IQueryFilter
Set pQf = New QueryFilter
pQf.WhereClause = "PHOTO_NO = " & frmRamp.txtPhoto.Text& And "WARD =" & frmRamp.txtWard.Text&
   
' if it exists show message
If pFClass.FeatureCount(pQf) > 0 Then
MsgBox "Value already exists, try again!", vbOKOnly, "Forum Help"
frmRamp.Hide
frmRamp.Show
       
Exit Sub
End If

   

End Sub

Attachments

Outcomes