I have an access form that runs a query. However it runs a query using vba code and sometimes it searches the table for text fields and sometimes for number fields depending on the field they choose on a combo box in the form.
I have left a note that if they wish to search for a text field they must enter double quotes or the code will not work. However, if the user does not follow these directions they will get a popup that exlains the coding issue with the options debug and end. I do not want them to see this message.
Is there a way to suppress this error message and write my own?
Edit: Dim dbsCurrent As Database Dim qryTest As QueryDef
varWhere = "WHERE InclusiveParent." & Combo0.Value & "=" & Text2
varWhere = "select Location, IcmService, IcmScript, ThresholdVariable, PbxVdn, Domestic, FirstSecondLook, DNIS, Tollfree, Outdial, Description, Carrier, DefaultTollfree, BlockedRoute, Variable3, Variable4, Variable5, Variable9, ValueScrVdn, Cvp from InclusiveParent " & varWhere
'Filter frmCustomers based on search criteria
'Dim dbsCurrent As Database
'Dim qryTest As QueryDef
Set dbsCurrent = CurrentDb
Set qryTest = dbsCurrent.QueryDefs("Broaden")
qryTest.SQL = varWhere
'Close frmSearch
DoCmd.Close acForm, "SearchDependents"
InclusiveParent is a query that I'm requery-ing and Broaden is the requery. SearchDependents is the name of the Form. Combo0 is a combo box that lets them select which field to choose to filter. And Text2 is the text field that they enter the filter criteria in. However, not all fields are numbers, so when they choose to filter by a text field they must enter double quotes or the code fails.