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

Auto Populate Form using Combo Box's

Hello,

I'm using access 2007 and have one table (Assets). In my table there is a User field (Assets.User) and Deptartment. field (Assets.Department). On my form I have a combo box for User (cboUser) and a combo box for Department (cboDepartment). Currently they are both individual drop downs with the User and Group names listed in the row source.

On the form, the data entry person will select a user. Once that User is selected how do I autopopulate the Department field on the form?

Thanks,

Kevin
Dec 9 '08 #1
3 10101
If you don't have very many users a simple way would be to code the on change or after update (can't rememer which one off the top of my head) something like below. Also need to change the combobox for the department to a textbox. I hope this will help.

Expand|Select|Wrap|Line Numbers
  1. if comboboxUser is "Name1" then
  2. textbox = "Department 1"
  3. else if comboboxUser is "Name2"then
  4. textbox = "Department 2"
  5. end if
  6.  
Dec 9 '08 #2
Thanks Aric,

I have too many users to go throw this. Also I allow people to enter new User names in the user field. I'll have to update a file or the database to add the department.

I'm still not clear on how to link the user to his or her department.

Kevin
Dec 9 '08 #3
OldBirdman
675 512MB
Expand|Select|Wrap|Line Numbers
  1. Table = Assets
  2. Key Department User
  3. 1   Accounting John
  4. 2   Accounting Sue
  5. 3   Sales      Peter
  6. 4   Personel   Nancy
  7. 5   Accounting Frank
  8.  
I see your table as above. In this case, selecting User from a combo box would find a single Department, and no selection (and no combo box) would be necessary. The result would be a single Department. The code might be:
cboUser.ControlSource = "SELECT Department, User FROM Assets ORDER BY User;" In design view for your form, the Bound Column for cboUser would be 1 and the Row Source Type would be Table/Query. Then txtDisplayDepartment = cboUser would assign the Department to a text box, no operator action needed.

To work the other way, and select the Department, then cboDepartment.ControlSource = "SELECT Department FROM Assets ORDER BY Department;" Once selected (Change event), then cboUser.ControlSource = "SELECT User FROM Assets WHERE Department=""" & cboDepartment & """ ORDER BY User;" Both of these combo boxes have the bound column = 1.

You will have to set Column Count and Column Widths for these combo boxes in design view. In the first example, Column Widths will be 0";2" or whatever you need, but the 0" hides the first column.

Better database design would have 2 tables, Departments and Users. The FROM clause would change in the above examples.

OldBirdman
Dec 9 '08 #4

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

Similar topics

0
by: BK | last post by:
Hi, I have a problem. I need to auto populate fields based on a value entered in combo box. Initially, I put all the required fields in the combo box, and hide it (set to 0",0",0", ...), then...
4
by: godber | last post by:
I need to populate text boxes for instance with employee information using their unique employee works number selected from a combo box. Can anyone help, I am told thru visual basic this can be...
1
by: Jim | last post by:
I have a new database in which I have a form where in one field I type a letter A, B, C or D and the field next to it autofills (auto lookups) with a description associated with the specific...
2
by: CrazyAL | last post by:
I am working on a form to add entries into my assets table. I am trying to figure out how to make a purchase price field auto populate after entering model number into a combo box. There maybe a...
4
by: scolivas | last post by:
I think this is a me thing. but can't remember how to do it. I have a form that I am using and would like for a txt box to automatically populate based on what is selected in a combo box. here...
1
by: Captdreamer | last post by:
Hi there, As it will be very apparent in a moment, I am very new to Access and learning on the fly. (Much fun, but frustrating at the same time) I currently am trying to get a Combo Box that I...
4
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt...
5
by: giandeo | last post by:
Hello Experts. Could you find a solution for this problem please! I have the following tables in Access Database Table Name: origin Fields Names: country, countrycode Table Name: make...
2
by: Ronald | last post by:
I hope somebody can help. I can't get into the specifics of my project, but I'll try to create a simple example: tblVehicle * VIN (text box) * Make (text box) * Model (text box) frmRepair
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.