473,395 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Searching with stLinkCriteria

Hello,

I have the following script which I need to modify:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command231_Click()
  2. On Error GoTo Err_Command231_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "Main Table"
  8.  
  9.     stLinkCriteria = "[CaseName]=" & Me![NameSearch] 
  10.     If IsNull([Forms]![Menu]![NameSearch]) Then
  11.         MsgBox "You actually need to enter information first. Weird, huh?"
  12.     Else
  13.         DoCmd.OpenForm stDocName, , , stLinkCriteria
  14.         DoCmd.Close acForm, "Menu", acSaveNo
  15.     End If
  16.  
  17. Exit_Command231_Click:
  18.     Exit Sub
  19.  
  20. Err_Command231_Click:
  21.     MsgBox Err.Description
  22.     Resume Exit_Command231_Click
  23.  
  24. End Sub
Essentially, I need two things: (1) Change the criteria from an exact match to a partial text match and (2) search not only on the CaseName field, but also on the InsuredName field at the same time.

Suggestions?

Thanks much in advance,
NHAnimator
Sep 25 '07 #1
5 3675
cyberdwarf
218 Expert 100+
Use the LIKE keyword, instead of "="
Something like:-
Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = '[CaseName] Like('" & Forms!Menu![NameSearch] & %') Or [InsuredName] Like('" & Forms!Menu![NameSearch] & "%)'"
HTH

Steve
Sep 25 '07 #2
FishVal
2,653 Expert 2GB
Use the LIKE keyword, instead of "="
Something like:-
Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = '[CaseName] Like('" & Forms!Menu![NameSearch] & %') Or [InsuredName] Like('" & Forms!Menu![NameSearch] & "%)'"
HTH

Steve
Wildcard '%' is a part of ANSI SQL. Access by default supports its own dialect where '*' is used for the same purpose unless SQL syntax is set to ANSI.
See also Issue with Select not returning data to recordset

Regards,
Fish
Sep 25 '07 #3
cyberdwarf
218 Expert 100+
Sorry, Fish. I assumed "straight" SQL ;-)

Steve
Sep 25 '07 #4
FishVal
2,653 Expert 2GB
;-)

Apologizes not needed.
Sep 25 '07 #5
subscribing here Ignore me.
Sep 25 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: universal | last post by:
Hello all, Iam a complete beginner, so please be gentle. Im trying to (if possible) create a form to be used as a "search" facility of another form. All users list their favourite foods:...
0
by: cwm137 | last post by:
I have a form named "Customer Search" with a subform called "Cust Search Subform" that contains summary data about every order a customer has made. I would like to be able to select a single order...
8
by: Gordon Knote | last post by:
Hi can anyone tell me what's the best way to search in binary content? Best if someone could post or link me to some source code (in C/C++). The search should be as fast as possible and it would...
5
by: justobservant | last post by:
When more than one keyword is typed into a search-query, most of the search-results displayed indicate specified keywords scattered throughout an entire website of content i.e., this is shown as...
4
by: elainenguyen | last post by:
I am trying to write a code that seaching a record in 3 tables and if the record exist, show the data, if the record doesn't exist, show the warning message. The following is my code that I am...
7
by: pbd22 | last post by:
Hi. I am somewhat new to this and would like some advice. I want to search my xml file using "keyword" search and return results based on "proximity matching" - in other words, since the search...
3
by: ruthboaz | last post by:
Hi, I have a numeric Field RFINo and a Yes/No Data type for Issued stLinkCriteria = " = " & lstRFINo.Value & " And = Yes" With the above I am not getting the specific record. Pls advice.
2
by: mark mestrom | last post by:
hi, i have this problem with OpenForm and the stLinkCriteria. I have the following code: Private Sub Knop22_Click() On Error GoTo Err_Knop22_Click Dim stDocName As String Dim...
4
by: crazyhouse | last post by:
This is the line of code i am trying to use. It doesnt work. I want the form to open only records that match the inspectjn, and accqty isnull. inspectjn is text accqty is a number ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.