473,413 Members | 1,778 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,413 software developers and data experts.

Changing Search Criteria

Ok I have the following code which allows the users to search by Client Id No -- but they would prefer to search by Client_First_Name & Client_Surname (which are two fields in tblClient Details). I have been having a go at this & can change the search to search on Client_Surname but this only shows the first record with that surname. What I would like is for the user to enter First Name Surname in the text box(es) & click the search button & pull back all the clients with that name. Is it possible to convert what I have code wise to do this??




Expand|Select|Wrap|Line Numbers
  1. Private Sub Command53_Click()
  2. Dim strClientIdNo As String
  3.     Dim strSearch As String
  4.  
  5.     If IsNull(Me![Text54]) Or (Me![Text54]) = "" Then
  6.         MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
  7.         Me![Text54].SetFocus
  8.     Exit Sub
  9. End If
  10.  
  11.     DoCmd.ShowAllRecords
  12.     DoCmd.GoToControl ("Client_Id_No")
  13.     DoCmd.FindRecord Me!Text54
  14.  
  15.     Client_Id_No.SetFocus
  16.     strClientIdNo = Client_Id_No.Text
  17.     Text54.SetFocus
  18.     strSearch = Text54.Text
  19.  
  20.     If strClientIdNo = strSearch Then
  21.         MsgBox "Match Found For: " & strSearch, , "Congratulations!"
  22.         Client_Id_No.SetFocus
  23.         Text54 = ""
  24.  
  25.          Else
  26.             MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
  27.             , "Invalid Search Criterion!"
  28.             Text54.SetFocus
  29.     End If
  30. End Sub
Sep 10 '07 #1
2 1665
Forgot to mention I posted this a little while a go with a slightly different title but I seem to have posted it under Access Articles --- could one of the mods please delete that one for me
Sep 10 '07 #2
Jim Doherty
897 Expert 512MB
Ok I have the following code which allows the users to search by Client Id No -- but they would prefer to search by Client_First_Name & Client_Surname (which are two fields in tblClient Details). I have been having a go at this & can change the search to search on Client_Surname but this only shows the first record with that surname. What I would like is for the user to enter First Name Surname in the text box(es) & click the search button & pull back all the clients with that name. Is it possible to convert what I have code wise to do this??




Expand|Select|Wrap|Line Numbers
  1. Private Sub Command53_Click()
  2. Dim strClientIdNo As String
  3.     Dim strSearch As String
  4.  
  5.     If IsNull(Me![Text54]) Or (Me![Text54]) = "" Then
  6.         MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
  7.         Me![Text54].SetFocus
  8.     Exit Sub
  9. End If
  10.  
  11.     DoCmd.ShowAllRecords
  12.     DoCmd.GoToControl ("Client_Id_No")
  13.     DoCmd.FindRecord Me!Text54
  14.  
  15.     Client_Id_No.SetFocus
  16.     strClientIdNo = Client_Id_No.Text
  17.     Text54.SetFocus
  18.     strSearch = Text54.Text
  19.  
  20.     If strClientIdNo = strSearch Then
  21.         MsgBox "Match Found For: " & strSearch, , "Congratulations!"
  22.         Client_Id_No.SetFocus
  23.         Text54 = ""
  24.  
  25.          Else
  26.             MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
  27.             , "Invalid Search Criterion!"
  28.             Text54.SetFocus
  29.     End If
  30. End Sub
If you send me your email by PM I will mail you a fully functional demo of how you can search fields in combination with each other using wildcards also with the ability to output the returned dataset to excel if you wish and also add to the same table of people all from the same form. It has a number of techniques you might find useful in your learning process

Regards

Jim
Sep 10 '07 #3

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

Similar topics

1
by: windandwaves | last post by:
Hi Folk, Below is a message that I posted on alt.html I now have some more feedback from people who experienced an error with safari and they tell me that the PHPsessID changes while running a...
1
by: N. Graves | last post by:
Hi, I want to have a Search Dialog box that has several text box and fields to build a search and display the results in a form. I can do everything that I need to if I us a report but I would...
4
by: Jan | last post by:
I am having problems trying to print a report based on a form. This is a search form only, no data input. There is a query that the form looks at, but then there are numerous comboxes that you...
3
by: Russell | last post by:
Hey, ok i have numerous tables to search through for a 'site search'. some of the searchble fields have html embeded within so after some quick referencing, saw I can use the regExp function...
6
by: shantanu | last post by:
Hi All, I have a requirement to develop a search engine based on some search criteria that will search for the string or statement in all the documents uploaded in the website. The search result...
4
by: bendlam | last post by:
I have a page that contains search criteria and when you click on the search button it causes a post back that populates a dataview on the same page. One of the gridview columns contains a link...
1
by: DrJarmin | last post by:
Hello The problem is this: in the criteria for a list box I reference the parent form - and Access KEEPS changing the criteria for one that won't work. Details below: I have a couple of list...
2
by: MNNovice | last post by:
I am working on a database on my CD collection using Access 2003. Some of the table structures are given below. Table 1 tblMusicCategory Field 1: MusicCategoryID - Auto Number (PK) Field 2:...
3
by: Darkside12 | last post by:
Hi, I'm trying to build a dynamic query by form. The idea is that a user can select a table in the database via a combo box and this will then change all of the text box labels on the form to...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.