[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Wildcard on form filter?

Posted on 2006-05-30
9
Medium Priority
?
453 Views
Last Modified: 2011-09-20
How can this code be amended so that the user can filter on wilcards?

DoCmd.OpenForm "frmEngView", , , "[Surname] = '" & txtEngSurname & "'"



Thanks
Lapchien


0
Comment
Question by:Lapchien
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 7

Expert Comment

by:Jonathan Kelly
ID: 16789759
Hi Lapchien ,


try
DoCmd.OpenForm "frmEngView", , , "[Surname] like '" & txtEngSurname & "'"

0
 

Author Comment

by:Lapchien
ID: 16789782
Does not work - I alrady tried that - if the full surname is Mearing and I enter mear I get no results returned...

0
 

Author Comment

by:Lapchien
ID: 16789786
If I add my own * at the end of the filter it works though - do I add it at the end of the code?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 7

Assisted Solution

by:Jonathan Kelly
Jonathan Kelly earned 1600 total points
ID: 16789795
you need to enter mear* OR

you need to modify your criteria to something like

DoCmd.OpenForm "frmEngView", , , "[Surname] like '" & txtEngSurname & "'" & "*"




0
 

Author Comment

by:Lapchien
ID: 16789849
Something like that yes - but your example doesn't work :(
0
 
LVL 7

Expert Comment

by:Jonathan Kelly
ID: 16789917
:(

ok hold tight. I'll pull some old code.
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 16789932
put the wildcards in
I think Datrias was almost there


DoCmd.OpenForm "frmEngView", , , "[Surname] = '*" & txtEngSurname & "*'"
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 400 total points
ID: 16789944
ooops, typo in copy/paste, I forgot the LIKE



DoCmd.OpenForm "frmEngView", , , "[Surname] LIKE '*" & txtEngSurname & "*'"


are your surname likely to include single quotes?

If so then do this

DoCmd.OpenForm "frmEngView", , , "[Surname] LIKE " & chr$(34) & "*" & txtEngSurname & "*" & chr$(34)

0
 
LVL 3

Expert Comment

by:RemounM
ID: 16789992
I would try appending asterisks before and after the query part, in the code itself..

DoCmd.OpenForm "frmEngView", , , "[Surname] like '*" & txtEngSurname & "*'"


But then again, that's a completely random thought.. Oh well, try it. ;)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question