Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Command Button to Open Form and Filter using Wildcard

Posted on 2013-12-11
3
Medium Priority
?
1,268 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 39

Accepted Solution

by:
PatHartman earned 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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. …

609 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