Solved

MS Access Filter from a Command Prompt with Wildcard

Posted on 2010-09-08
3
411 Views
Last Modified: 2012-05-10
I have an Access 2003 database.  In this database I have a form with a command button I'm trying to code with a filter in the prompt.

Dim stDocName As String
  Dim stLinkCriteria As String
  Dim strFindID As String
  Dim AssignedTo As String
   strFindID = InputBox("Enter Country (or leave blank for all)")
      If strFindID = "" Then
        stDocName = "frmTicOpenAsgn"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
          Else
        AssignedTo = strFindID
        stLinkCriteria = "[AssignedTo]=" & "'" & strFindID & "'"
        stDocName = "frmTicOpenAsgn"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
      End If
        DoCmd.Maximize


I want to change the strFindID to the following but I can't figure out how to get it to work.

Like "*" & [Enter Country (or leave blank for all)] & "*"

Any ideas?

Thank you so much!
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 33626287
change this

 stLinkCriteria = "[AssignedTo]=" & "'" & strFindID & "'"

with


 stLinkCriteria = "[AssignedTo] like '*" & strFindID & "*'"
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 33626338

altering your codes to get all when nothing is entered in the input box



Dim stDocName As String
  Dim stLinkCriteria As String
  Dim strFindID As String
  Dim AssignedTo As String
   strFindID = InputBox("Enter Country (or leave blank for all)")
      If strFindID = "" Then
        stDocName = "frmTicOpenAsgn"
        stLinkCriteria = "[AssignedTo] like '*'"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
          Else
        AssignedTo = strFindID
         stLinkCriteria = "[AssignedTo] like '*" & strFindID & "*'"
        stDocName = "frmTicOpenAsgn"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
      End If

Open in new window

0
 

Author Closing Comment

by:Senniger1
ID: 33626383
Absolutely what I needed.

Many thanks!
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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.
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…

737 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