473,785 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Searching by unique ID text boxes or name combo boxes

114 New Member
I have an Access database of employees.
Each employee has a unique identification number called "BANNER_ID" .
Each employee's last name and first name are in the database but are not unique (obviously).
The data is stored in a table named EMPLOYEE.

I want to create a search option whereby managers can search for an employee by "BANNER_ID"
by entering the number and pressing a command button named "Search".

I want to create an accompanying search option whereby managers can search for an employee
by selecting his or her last name from a combo box (LAST_NAME) and then first name from
another combo box (FIRST_NAME).
When a last name is selected, I would like the combo box of first names to narrow to only
first names that are associated with the selected last name.

I want both search options to be available.

I have been helped with the following code that searches for employees based on their
last name. However, I am having trouble adapting it to work with my new needs listed above.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSearch01_Click()
  2.     Dim strStudentRef As String
  3.     Dim strSearch As String
  4.  
  5. 'Check txtSearch01 for Null value or Nill Entry first.
  6.  
  7.     If IsNull(Me![txtSearch01]) Or (Me![txtSearch01]) = "" Then
  8.         MsgBox "Please enter a last name!", vbOKOnly, "Martin DH Message"
  9.         Me![txtSearch01].SetFocus
  10.     Exit Sub
  11. End If
  12. '---------------------------------------------------------------
  13.  
  14. 'Performs the search using value entered into txtSearch01
  15. 'and evaluates this against values in LAST_NAME
  16.  
  17.     DoCmd.ShowAllRecords
  18.     DoCmd.GoToControl ("LAST_NAME")
  19.     DoCmd.FindRecord Me!txtSearch01
  20.  
  21.     LAST_NAME.SetFocus
  22.     strStudentRef = LAST_NAME.Text
  23.     txtSearch01.SetFocus
  24.     strSearch = txtSearch01.Text
  25.  
  26. 'If matching record found sets focus in LAST_NAME and shows msgbox
  27. 'and clears search control
  28.  
  29.     If strStudentRef = strSearch Then
  30.         MsgBox "Match Found For: " & strSearch, , "Martin DH Message"
  31.         LAST_NAME.SetFocus
  32.         txtSearch01 = ""
  33.  
  34.     'If value not found sets focus back to txtSearch01 and shows msgbox
  35.         Else
  36.             MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
  37.             , "Martin DH Message"
  38.             txtSearch01.SetFocus
  39.     End If
  40. End Sub
  41.  
I would appreciate any help available in developing these search options. Thank you!

Martin DH
Mar 22 '07
11 2693
martin DH
114 New Member
I'm sorry; I don't understand why the BANNER_IDs would not be the same thing. As a user searches for an employee via the combo boxes, the matching records appear in the list box, the user should then be able to click on a record, which opens the record in the form below so that the user can review/edit the record. This happens because when a record is selected, the db pulls the full record and displays it based on the BANNER_ID that matches one in the EMPLOYEE table. BANNER_ID is the unique id for the employee records. Could you explain where my logic is falling short and if there is a way to accomplish this task? Thanks so much!

Martin DH
Apr 24 '07 #11
Rabbit
12,516 Recognized Expert Moderator MVP
I'm sorry; I don't understand why the BANNER_IDs would not be the same thing. As a user searches for an employee via the combo boxes, the matching records appear in the list box, the user should then be able to click on a record, which opens the record in the form below so that the user can review/edit the record. This happens because when a record is selected, the db pulls the full record and displays it based on the BANNER_ID that matches one in the EMPLOYEE table. BANNER_ID is the unique id for the employee records. Could you explain where my logic is falling short and if there is a way to accomplish this task? Thanks so much!

Martin DH
If the form is bound to a row source, i.e. a table, query, etc., then it has access to those fields for whichever record it is on. So Me.FieldName refers to the field of that record. A bound control is linked to a field while an unbound control is not. So if the control named ControlA is bound to a field named FieldA, there are two ways to access and change that value. One is through the field name. Me.FieldA, the other is through the control, Me.ControlA. A listbox, can only return one value and can only be bound to one field. A listbox only displays values.

So let's say you have a form, FormA, that is bound to table TableA with 5 records, and it has a field called ID.

Let's also say you have a listbox called ListA which displays all the IDs from TableA.

So, when you open the form and it starts on the first record, the form's ID value is the first ID value. When you click a different record on that list, it does NOT change the form's ID value, it changes the value that the List returns.
Apr 24 '07 #12

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

Similar topics

1
10619
by: Mike | last post by:
I have a combo box and a text box. Text to be display will be contigent upon what is selected via the combo box. How do I do this? I put the following code in the text box object: var a = get thisField("combobox") If (a==1) { event.value = "Test1"
1
2156
by: Serious_Practitioner | last post by:
This is such a simple problem. I've asked for, and gotten, help with this in the past, and I can't make this work. Once more, please - I want to be able to put a member number (which is the primary key of a table called tblMemberInfo) into a text box on an unbound form and get back, in some other text boxes, other information (name, e-mail address and date of birth, say) from the same table. I also want to get, from a table called...
3
4279
by: Frustrated Developer via DotNetMonster.com | last post by:
I have posted a couple times on here already and found the user community to be very helpful. I took on a project before I realized how difficult a time I'm having working with a database. Assistance would be greatly appreciated! I am trying to allow certain users to be able to preview a database's contents without being able to update which I've accomplished. I've created a "Preview" button and set the datagrid to READ ONLY. Now I want...
2
1796
by: Bill Brinkworth | last post by:
in vb.net 2005, i would like to pull up a name from a database (customers) (i can do this already), then after a name is selected from a combox box, to populate the form's text boxes with with data about that customer. I.E.: if john is selected from the combo, i would like to have his address, city, etc. filled out in the text boxes. I do not want to populate a listbox or datagrid.....I do these easy as pie in Access but i just can not do...
7
2419
by: evilcowstare via AccessMonster.com | last post by:
Hi, I have searched the forum for answers on this and to be honest as a novice I find it a bit confusing so apologies if it is simple. There are some searches that I want to apply to my database. 1. To search for all records between 2 dates and display them in a report 2. To be able to show all records which have a selection against them made from a combo box 3. To be able to combine the two, selecting the option from a combo and then...
2
3624
by: jw01 | last post by:
I have a form in which there is one combo box and three text boxes: Combo Box: -> Item A -> Item B -> Item C TextBox1: TextBox2: TextBox3:
1
2908
by: Dave | last post by:
Hello all, First I'd like to apologize...This post was meant to be put in my previous post, but I tried many times without success to reply within my previous post. Now here goes... I have a main form (RD Form) with 4 combo boxes (i.e. cbo1, cbo2, etc) and a subdatasheet (the subform...let's call it subInfo) below the combo boxes on the RD Form. I hope this eliminates any confusion of the
9
5006
by: Marianne160 | last post by:
Hi, I know there are various answers to this problem available on the web but none of them seem to work for me. I am using Access 2003 to make a form to look up data from a table. I have so far created three combo boxes that cascade down from Name to Project to Date and when this has been chosen I have four textbox fields I want to display based on this selection. I tried linking the last combo box comboDate to update these fields after...
2
4618
by: SHAWTY721 | last post by:
I have a form that contains two combo boxes that are related to each other. I need to find a way to populate my text box based on the criteria of the two combo boxes so the appropriate number appears in the text box.
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10356
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.