Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 29th, 2005, 09:49 AM
Danny_Access Danny_Access is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 20 Danny_Access User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 37 m 49 sec
Reputation Power: 0
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!

Reply With Quote
  #2  
Old July 29th, 2005, 11:30 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
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

Reply With Quote
  #3  
Old July 31st, 2005, 11:13 AM
Rishyraj Rishyraj is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 53 Rishyraj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 29 m
Reputation Power: 4
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

Reply With Quote
  #4  
Old August 1st, 2005, 05:16 AM
Danny_Access Danny_Access is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 20 Danny_Access User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 37 m 49 sec
Reputation Power: 0
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.

Reply With Quote
  #5  
Old August 1st, 2005, 09:18 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 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

Reply With Quote
  #6  
Old August 1st, 2005, 09:24 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
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

Reply With Quote
  #7  
Old August 1st, 2005, 10:40 AM
Danny_Access Danny_Access is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 20 Danny_Access User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 37 m 49 sec
Reputation Power: 0
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!

Reply With Quote
  #8  
Old August 1st, 2005, 10:57 AM
Danny_Access Danny_Access is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 20 Danny_Access User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 37 m 49 sec
Reputation Power: 0
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!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Automatic display of text


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT