Solved

Command Button to Open Form and Filter using Wildcard

Posted on 2013-12-11
3
1,149 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
ID: 39711995
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
ID: 39712036
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
ID: 39712259
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

947 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

19 Experts available now in Live!

Get 1:1 Help Now