Solved

Command Button to Open Form and Filter using Wildcard

Posted on 2013-12-11
3
1,176 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 36

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

733 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