3 Replies - 549 Views - Last Post: 14 January 2009 - 09:10 AM

#1 staticz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 14-January 09

Need help with VBA and Access

Posted 14 January 2009 - 08:50 AM

Sorry for the double post

This post has been edited by staticz: 14 January 2009 - 08:55 AM

Is This A Good Question/Topic? 0
  • +

Replies To: Need help with VBA and Access

#2 staticz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 14-January 09

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.

 '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.
Was This Post Helpful? 0
  • +
  • -

#3 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1511
  • View blog
  • Posts: 5,916
  • Joined: 21-March 08

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 "


Was This Post Helpful? 1
  • +
  • -

#4 staticz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 14-January 09

Re: Need help with VBA and Access

Posted 14 January 2009 - 09:10 AM

View Posteclipsed4utoo, on 14 Jan, 2009 - 07:58 AM, said:

I think MS Access supports the "LIKE" keyword

strWhere = strWhere & "m.NAME LIKE " & Chr(34) & "%" & txtName.Value & "%" & Chr(34) & " AND "




Ahh I was close but had my LIKE in a different spot. Thanks for the help!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1