|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Automatic display of text
Hi,
I have a form which has a combo box of which the user enters an employee number e.g. 12345. I would like another box which displays the name associated with that number to display. For example.... I enter the Employee number "12345" and then a label, text box (dont know which!?!) automatically displays the associated name e.g. "Danny" next to it. Currently the table is setup with the following rows.... "Employee number" and "Employee Name". Thanks, its appreciated very much! |
|
#2
|
|||
|
|||
|
If the second column in your combobox has the Employee Name then you can use the column number to fill either the caption property of a label or the value of a textbox. Column numbers always start with 0 for the first column.
Label.Caption = combobox.column(1) TextBox = combobox.column(1) Or you can use the DLookup function Label.Caption = DLookup("[Employee Name]","TableEmployees","[Employee Number]=" & combobox) TextBox = DLookup("[Employee Name]","TableEmployees","[Employee Number]=" & combobox) Just use the actual names for the fields in your table and the controls on your form. lwells |
|
#3
|
|||
|
|||
|
Iwells,
My problem is similar to the one you replied on this post. The only twist is that instead of the name being displayed in the text box based on the employee number selected on the combo box. I want the employee name (my case requires borrower id) to update in the table. That has loan numbers autoincrement. For example. I have loannumber table with following fields. Table 1: Loannumber (autoincrement) BorrowerId (from table2) ToggleButton (yes/no) Table2: BorrowerId Name Amount I have designed a form with datasoure as table1. I have a combo with datasource as Table2. The user selects borrowerid from the combo and makes a tick in the toggle button that generates a loan number (autoincrement field). Now i want the borrower id number to be updated against the loan number in the table1. Is this possible. Thanks in advance |
|
#4
|
|||
|
|||
|
Hi.
Would that method work for multiple names and numbers or just for one? Also, been "noobish" could you break down how to implement the DLoopup function etc please? Thanks again. ![]() |
|
#5
|
|||
|
|||
|
Danny,
I will make some assumptions here. You have a table Employees named "tblEmployee" with two fields [EmployeeNumber] and [EmployeeName] (Note: I do not have spaces between the names in the fields which is recommened) and you have a combobox with the name Combo1 and a textbox named Text1 on your form. Your combobox has two columns, Column 0 contains the [EmployeeNumber] and is the bound column. Column 1 contains the [EmployeeName]. Notice the first column always starts with 0. The format of the combobox is: Column Count = 2, Column Widths = 1";0" which hides the second column from view. You can change the 0" to any length in inches you would like so that it can be viewed if you want when the combobox is opened. To use the DLookup function in the After Update event of the combobox would look like this: Text1 = DLookup("[EmployeeName]","tblEmployee","[EmployeeNumber] =" & Combo1) English translation: Look up the "[EmployeeName]" from the table "tblEmployee" where the "[EmployeeNumber]" equals the bound column of Combo1. Does this help any? lwells |
|
#6
|
|||
|
|||
|
Rishyraj,
Use the same append query that you use to establish the autoincrement for your loan number and add the field BorrowerId and set the criteria to the appropriate column from your combo box. If your combo box has the first column with the BorrowerID and the second column the BorrowerName, then the criteria would be Combobox.Column(0) for the ID and Combobox.Column(1) for the BorrowerName. If you can alter your tables, I would recommend to change the Name to BorrowerName to avoid any problems later on as this is an Access Constant that you are using as a field name. lwells |
|
#7
|
|||
|
|||
|
Thanks,
I dont thinik ive made it perfectly clear, or maybe im not totally understanding what you say! lol! Ok, so i have a table called "STAFF" this table has "Emp_Number" & "Emp_Name". The Emp_Number has around 50 entries of unique numbers and in a record alongside they have a name attached. So for example on record will have |Emp_Number|Emp_Name| 12345 | Danny Basically on the form i want to be able to select from a combo box the Employee Number, then immediately alongside the Employee Name will appear. The reason for this is incase our employees select the wrong Employee Number for the corrosponding name. Hope that makes sense. Thanks, again! |
|
#8
|
|||
|
|||
|
Ignore that last post. Ive just made a combo box with the other columns i require included like you mentioned earlier. For some reason that went straight over my head!
Works perfectly fine now and exactly what i need. Thanks again, you guys rock! ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Automatic display of text |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|