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

Get Name of Current VBA Function
MS Access 2010: How do forms communicate values to each other?
MSAccess - populate text box with value from query
How do I revert to default System.mdw after doing a SetDefaultWorkgroupFile?
ms-access 2007 runtime and lockWindowUpdate
Show Report Pages Count Only On Print
Custom Record Navigation
How to lock specific rows in a subform when a form loads?
If [ComboBox] Is Null Statement in VBA/Access 2007
Check Microsoft Access Form Values before Save
Is there any way to destroy MDW reference
vba check if specific process task id is still running
Access exports only 1st column of query
make a table in MS Access
how to get this code into a access form as text label?
Event not Firing in MS Access VBA

Categories

HOME
server
angular-material
android-4.4-kitkat
at-command
rdf
jgroups
ip
podio
slick-slider
gnupg
moonmail
normalizr
textfield
kryo
cloudhub
icloud-api
rundeck
qhull
status
pingfederate
applozic
ping
quote
twilio-api
uisplitview
noraui
column-family
pim
language-concepts
y86
mapdb
sequential
html5-fullscreen
plsql-psp
io-redirection
space-complexity
vapor
document.write
fedex
gzipstream
scrollable
jlink
kbuild
typed-lambda-calculus
windows-mobile-6.5
r-forge
arrow-keys
dynamics-sl
webdriverjs
libpng
log4c
two-factor-authentication
spidermonkey
embedded-code
deis
cisco-ios
mmc
streambase
jsapi
geonetwork
winddk
android-nested-fragment
neolane
article
aapt
braille
oam
cdc
buster.js
yui-compressor
dmoz
libstdc++
coderush
postgresql-performance
amazon-appstore
mercurial-server
window-management
xtype
calling-convention
lpeg
visitor-statistic
yslow
gamma
routedevent
castle-monorail
ncqrs
meego
audio-capture
ubuntu-9.04

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