Solved

Command Button to Open Form and Filter using Wildcard

Posted on 2013-12-11
3
1,136 Views
Last Modified: 2013-12-11
We have Office 2010.  In Access 2010 I have a form named "frmDocket".  On this form I have a Text Box named "txtInitials".  I also have a Command Button which opens the form "frmDktAtty".  On the form "frmDktAtty" I have a field named "RoutedTo".

When you click the Command Button on the form "frmDocket" it currently filters with the logic (txtInitials = RoutedTo).

Here is my code:
    DoCmd.OpenForm "frmDktAtty", acNormal, "", _
    "[RoutedTo]LIKE " & "'" & "*" & Me![txtInitials] & "*" & "'", , acNormal

What I really need is the following logic, but I cannot figure out how to alter my code (above) without getting an error.  I've tried so many variations so please don't ask me what I've already tried.

txtInitials = (Like "* [RoutedTo]*")

Can anyone assist me with this.

Thanks in advance!
0
Comment
Question by:Senniger1
  • 2
3 Comments
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
Comment Utility
Are you really supplying only a partial string?  If you are supplying the actual initials then you should not be using like:

 DoCmd.OpenForm "frmDktAtty", acNormal, "", _
    "[RoutedTo] = '" & Me![txtInitials] & "'", , acNormal

If you use like, then

DoCmd.OpenForm "frmDktAtty", acNormal, "", _
    "[RoutedTo] Like  '*" & Me![txtInitials] & "*'", , acNormal
0
 

Author Comment

by:Senniger1
Comment Utility
The "txtInitials" field contains the User's initials like LDM, for example.

The "RoutedTo" field contains entries like the following:
   JDP, AXT, LDM
   MEN, LDM, MCP, PCV
   PXT, JDP, JJK
   LDM, JJK

I'm tring to filter so that when LDM is in the "txtInitials" field, then only the records which contain LDM in the RoutedTo field appear.
.
0
 

Author Closing Comment

by:Senniger1
Comment Utility
I used the following and it worked.

DoCmd.OpenForm "frmDktAtty", acNormal, "", _
    "[RoutedTo] Like  '*" & [txtInitials] & "*'", , acNormal

I realized I had another filter on my form which was causing some of my attempts to fail.

Thanks so much!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now