I have a continuous form in ms access 2010 which is filtered by a textbox in which the user inputs a number. The filtered field in the underlying data table is of data type number, which also reads Long Integer in table design view. I assume the textbox delivers a string, so my after update method for the textbox converts the textbox.Value to a numeric format before setting the filter parameter code. The problem is that every way I try to cast the filterval variable results in a different error. Casting filterval as Long results in error 3464 data type mismatch in criteria expression at the line:
.Filter = "[ClientNumber]='" & filterval & "'"
How do I change my code so that the after update method can filter the form without error, given that the ClientNumber field in the data table is Long Integer? Here is my current code for the after update method of the txtFilter textbox:
Dim filterVal As Long
filterval = CLng(txtFilter.Value)
With Forms!Main!NavigationSubform.Form!NavigationSubform.Form
.Filter = "[ClientNumber]='" & filterval & "'"
.FilterOn = True