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

Printing an Access report and decimal place weirdness
Extract OLE object containg images using VBscript
ms access query results display problems
Record cannot be read; no read permission on 'MSysObjects'
VBA “delete” button in MS Access 2007
MS Access Typecasting Number to Double
Macro across multiple word documents
MS Access tables match and synchronize
Where can I give permission to read MSysObjects in ACCESS 2007? (not 2003)
How to use Controls collection in Access 2003 and VBA
Events in MS Access 2007
MS-ACCESS: displaying the results of a query in a message box
MS Access 2003 - Opening a report without it printing
Create a field name from a recordset
How run an Access 2007 module in VB6?
MS Access 2003 - Auto assigning an Identification Number

Categories

HOME
testng
asp.net-core
magnific-popup
appx
sd-card
rubygems
fancybox
swagger-ui
webrequest
esper
spring-xd
resize
n-gram
decimal
dynamics-crm-online
django-simple-history
opentracing
seaborn
ef-migrations
facebook-page
apache-metamodel
google-cloud-speech
dbext
kryo
intentfilter
orleans
kvc
cultureinfo
captiveportal
numerical-methods
cas
virtualdub
spring-mybatis
strncpy
gitignore
socialengine
media-queries
google-rich-snippets
create-table
contact-form
kendo-ui-grid
normal-distribution
plsql-psp
restlet
xcode-extension
libvpx
withings
android-browser
user-controls
hibernate-tools
veracode
tropo
drupal-6
nativeapplication
np-complete
orthogonal
nested-sets
nxt
ado.net-entity-data-model
etsy
connect-by
make-install
bgp
bluemix-app-scan
natvis
teamcity-8.0
feedback
muse
angular-local-storage
unity5.2.3
c++03
cdt
applescript-objc
page-layout
spring-io
flash-builder4.5
rabl
html-editor
tinn-r
gdata-api
qtkit
asyncfileupload
nsobject
gcj
heartbeat
telerik-scheduler
gamma
filtered-index
sef
mtj
port-number
lzh

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