ms-access


I keep on getting an error 13 type mismatch error, How can I get it out?


In Access 2010 I am trying to create a search box for a table of contacts on a form.
Here is my code:
Private Sub Command119_Click()
On Error GoTo Command119_Click_Err
If (Eval("[Forms]![frmTitlePage]![SearchBox] Is Null")) Then
' Clear Filter when search box empty
DoCmd.RunCommand acCmdRemoveFilterSort
End If
' Handle "'s in search
TempVars.Add "strSearch", Replace(Forms!frmTitlePage!SearchBox, """", """""")
' Build the Filter
TempVars.Add "strFilter", "([Last Name] Like "" * " & [TempVars]![strSearch] & " * "" )"
TempVars.Add "strFilter", TempVars!strFilter & " OR ([First Name] Like "" * " & [TempVars]![strSearch] & " * "" )"
DoCmd.ApplyFilter "", TempVars!strFilter, ""
TempVars.Remove "strFilter"
TempVars.Remove "strSearch"
Command119_Click_Exit:
Exit Sub
Command119_Click_Err:
MsgBox Error$
Resume Command119_Click_Exit
End Sub
I am obviously horrible at this coding so any additional help to clean this search tool up would help tremendously.
You have some extra spaces in your search
Your original code produced Like " * Smith * "
remove the extra spaces around the place you add [TempVars]![strSearch] to produce this:
TempVars.Add "strFilter", "([Last Name] Like ""*" & [TempVars]![strSearch] & "*"" )"
TempVars.Add "strFilter", TempVars!strFilter & " OR ([First Name] Like ""*" & [TempVars]![strSearch] & "*"" )"
should now produce Like "*Smith*"

Related Links

Does Access 2013 still have an ACE database or equivalent?
Creating 2D (Data Matrix or QR Codes) in MS Access Reports/Forms
Mass Delete Individual Fields
Error on INSERT statement
Microsoft Access 2003 - Expression Builder
Reference existing expression
Automatically updated the textbox
Profiler for MSAccess
Access Switchboard Manager: Invalid Procedure Call or Argument
how should this SQL be written?
Data type for currency values in Access
Update top rows in Access table that match condition
Data type in access 2007
How to specify a custom format for a text pattern in Microsoft Access?
Many to Many in Access
MS Access (2010) VBA filter not working on one subform

Categories

HOME
ibm-bluemix
listview
oracle11g
isabelle
bpmn
amortized-analysis
infragistics
microservices
installshield
blueprintjs
azure-storage-tables
append
pheatmap
contact
esper
slick-slider
awesome-wm
communication
google-cloud-ml
spring-tool-suite
size
tostring
jsdoc
google-static-maps
apache-metamodel
jndi
claims-based-identity
xacml
procdump
sql-server-2012-express
fog
plsql-psp
code-search-engine
angularjs-factory
user-controls
optix
gzipstream
elmah
botbuilder
estimote
import-from-excel
checkboxlist
angular2-meteor
multipeer-connectivity
pnotify
svmlight
drupal-6
composite-key
sonarlint-vs
eventkit
pintos
yt-project
url-pattern
deadbolt-2
file-writing
asp.net-4.5
skobbler-maps
transmitfile
firebaseui
master-slave
dataview
php-internals
photobucket
phpcas
pundit
security-testing
coveralls
emailrelay
javax.mail
jscript.net
knuth
gui-test-framework
codeigniter-routing
googlemock
document-classification
wp-query
datagridviewcolumn
didselectrowatindexpath
gnu-smalltalk
tws
eclipse-memory-analyzer
xamlparseexception
enterprisedb
robotics-studio
free-variable
simba
first-responder
netdna-api
javax.script
servicehost
self-extracting
table-footer
actionview
getresponsestream
temporal-database
yagni
data-acquisition
.net-1.0

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App