This post has been edited by staticz: 14 January 2009 - 08:55 AM
Need help with VBA and Access
Page 1 of 13 Replies - 549 Views - Last Post: 14 January 2009 - 09:10 AM
#1
Need help with VBA and Access
Posted 14 January 2009 - 08:50 AM
Sorry for the double post
Replies To: Need help with VBA and Access
#2
Re: Need help with VBA and Access
Posted 14 January 2009 - 08:51 AM
Hey everyone I have been a lurker here for a long time but have a question that has me extremely confused. I am working on a form that allows the user to search the database by whatever field or combination of fields they would like. Where I am having trouble is figuring out how to allow for them to just search by a letter or part of a word. Is there anyway to code wildcards into VBA? Here is part of the code if it helps at all.
I really would like be able to search for just "Bank" and have every record with "Bank" in the owner's name come up.
Thanks.
'Owner's Name If Len(txtName.Value) <> 0 Then strWhere = strWhere & "m.NAME = " & Chr(34) & txtName.Value & Chr(34) & " AND " End If 'TKS Installed If Len(chkTKS.Value) <> False Then strWhere = strWhre & "m.TKS = " & chkTKS.Value & " AND " End If 'N-Number If Len(txtNNumber.Value) <> 0 Then strWhere = strWhere & "m.nNumber = " & Chr(34) & txtNNumber.Value & Chr(34) & " AND " End If 'Serial Number If Len(txtSerialNumber.Value) <> 0 Then strWhere = strWhere & "m.serialNumber = " & Chr(34) & txtSerialNumber.Value & Chr(34) & " AND " End If
I really would like be able to search for just "Bank" and have every record with "Bank" in the owner's name come up.
Thanks.
#3
Re: Need help with VBA and Access
Posted 14 January 2009 - 08:58 AM
I think MS Access supports the "LIKE" keyword
strWhere = strWhere & "m.NAME LIKE " & Chr(34) & "%" & txtName.Value & "%" & Chr(34) & " AND "
#4
Re: Need help with VBA and Access
Posted 14 January 2009 - 09:10 AM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|