Hi all,I am trying to set up an input box so users can select points by a date field. The user types in a "Date From" and a "Date To", and the selection is supposed to occur. However, as the code is, no selection occurs when the input boxes are used. If I were to do the selection manually with the Select by Attribute tool, the dates show up in the format of " date 'YYYY/MM/DD' ", and if I type dates in that format directly into the code, it makes the correct selections--but I get a type mismatch error if that's typed into the user boxes. Where am I going wrong?Ideally, I'd like the user to be able to type the date in the format of just MM/DD/YYYY, as that is how the dates are displayed in the attribute table, but whatever will work will do.Thanks in advance for any help!Public Sub GetDates()
Dim pDoc As IMxDocument
Dim pMap As IMap
Dim pActiveView As IActiveView
Dim pFeatureLayer As IFeatureLayer
Set pDoc = ThisDocument
Set pMap = pDoc.FocusMap
Set pActiveView = pMap
Dim pQueryFilter As IQueryFilter
Dim pFeatureSelection As IFeatureSelection
Dim DateFrom As Date
DateFrom = datDateFrom.Text
Dim DateTo As Date
DateTo = datDateTo.Text
'Other alternatives I can think of also don't work, such as:
'Dim DateFrom As String '(or Date)
'DateFrom = "date '" & datDateFrom.Text & "''
'Dim DateTo As String '(or Date)
'DateTo = "date '" & datDateTo.Text &"'"
Application.Document.CommandBars.Find(ArcID.Query_ClearSelection).Execute
Set pFeatureLayer = pMap.Layer(0)
'Prepare a query filter
Set pQueryFilter = New QueryFilter
pQueryFilter.WhereClause = "OccurredDate1 >= DateFrom And OccurredDate1 <= DateTo"
'Refresh the old selection, if any, and erase it
pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
'Select features
Set pFeatureSelection = pFeatureLayer
pFeatureSelection.SelectFeatures pQueryFilter, esriSelectionResultNew, False
'Refresh again to draw the new selection
pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
End Sub
Patricia PendletonCenter for Geographical StudiesCal State University, Northridge