Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Form Fields from Combo Box?

Status
Not open for further replies.

DMHamm

Technical User
Aug 1, 2003
8
US
You can't get much newer to Access than I am, so please bear with me.

I have two tables: tblLttrType that describes the type of letter an employee should get, and tblEmpSample in which I want to record survey data for which letter employees DID get, and whether it was on time. I'm trying to create a form that allows me to input the employee-specific data, but also shows me all the attributes of the letter that should have been sent. I'm stuck.

I thought I could put a combo-box on the form that would list the letter types in a 3-column drop-down. Once selected, the rest of the attribute fields would automatically populate so I could do a visual comparison against the letter they did get and mark off checkboxes. The problem is I don't know how to write the update query that would update the fields in the tblEmpSample with the attribute data from tblLttrType, and once written how to trigger it.

My second problem is the combo-box itself: no matter what I do, I can't get the field to show all 3 columns (they show in the drop-down list, but don't show once the selection is made). I have checked the Properties:Column width feature, even tried some VBA code I found in another thread ("Me!LttrTitle = Me![LttrTypeCombo].Column (1)"), but I can't get it to work.

I know this should be simple, but like everything else with computers: if you don't know it, it's like banging your head against the wall. Any help you can give would be MUCH appreciated - this is for a project at work and I can't afford to waste time on it. If I can't get it to work, I'm going to have to track my results in an Excel spreadsheet!!
 
YOu need to manually (thru code) set any other fields on the form. This can be done thru the click event

Each column in the combo box represents a field in the combo box's data source.

me.combo0.column(0) is the first column and
me.combo0.column(3) is the fourth.

If you wanted to set a form's field named "MyField" to the fourth value, you just code this:

me![MyField] = me.combo0.column(3)

All those brackets are not abs necessary but are good programming practise.

Rollie E
 
I've tried a lot of variations, including this one, but I keep getting the error: "Microsoft Access can't find the field "LttrTitle" in your expression." (LttrTitle is one of the fields from the tblLttrType table I selected for my combo-box drop-down.)How do I identify this field so Access can see it? Do I have to somehow include it on the form separate from the combo-box?
 
By the way, I'm doing this in the AfterUpdate Event Procedure - that is the place to do it, isn't it?
 
The combo box will only output the bound column. You have to get the others as I outlined above. I would do it on a click event.

If "Me!LttrTitle = Me![LttrTypeCombo].Column (1)" does not work, you do not have a bound field control on your form named "LttrTitle"


If you wish, send me a zipped copy of your file and I will look it over and return changes to you.

rollie@bwsys.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top