James,Just wanted to take a second and say thank you for all the help you gave me on this issue. You were right - while this:pQueryFilter.WhereClause = "MAXWSEL_FT = '" & var & "'" *didn't workthis:pQueryFilter.WhereClause = "MAXWSEL_FT = " & var *did, as long as I declared var as the proper type.My employer has had three programmers work on this specific tool over the course of several years. Your help is getting me big brownie points with those who pay my bills, and for that I can only say, "You da man!"Justin
More discoveries. The GIS team figured out that in some of their shapefiles, the data type had been switched from Double to Float, which apparently causes trouble when trying to query the attribute table. They're in the process of fixing that up.In the meantime, I switched to querying a different field, and am thrilled and horrified by what I have found. First the good news. If I hard code the field's value, things work perfectly! For example:pQueryFilter.WhereClause = "MAXWSEL_FT = 6322.9" returns the correct value and places it right where I want it in the table. Bravo! Now the bad news...As we all know, it does no good to have a hard coded value. I need a variable that can hold a value based on user input. First I tried to use the value directly from the combo box:pQueryFilter.WhereClause = "MAXWSEL_FT = '" & cbTransect1.EditText & "'"No luck. (FYI, cbTransect1.EditText's Type is String, which I didn't know until this afternoon)So I tried creating a different variable and converting cbTransect1.EditText to String, which I now know was redundant:Dim strRegion as StringstrRegion = CStr(cbTransect1.EditText)pQueryFilter.WhereClause = "MAXWSEL_FT = '" & strRegion & "'"Still no luck.Then I got the bright idea of storing the static value (the one that had worked earlier) in the strRegion variable. Would you believe that it didn't work either?Dim strRegion as StringstrRegion = "6322.9"pQueryFilter.WhereClause = "MAXWSEL_FT = '" & strRegion & "'" It seems like it just doesn't like anything when its passed in through a variable. I've seen loads of examples with this same syntax. Can anyone spot what's wrong with my SQL?
pQueryFilter.WhereClause = "DS_DIST_MI = '" & cbTransect1.EditText & "'"
Dim cbText as String cbText = CStr(Me.cboRateClass.SelectedValue.ToString) 'or try cbText = CStr(Me.cboRateClass.SelectedText.ToString) 'use this variable in your WhereClause pQueryFilter.WhereClause = "DS_DIST_MI = '" & cbText & "'"
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.