Solved

Command Button to Open Form and Filter using Wildcard

Posted on 2013-12-11
3
1,196 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 38

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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