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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate Field from selected value

Status
Not open for further replies.

nroberts420

Programmer
Jun 24, 2003
27
US
I'm using a combo box in a form. I want the user to be able to select a value in a combo box and then it will fill in a text box with the corresponding value. Example:
I have a list of "types" that have a "type ID". I want the user to be able to pick the "type" from a combo box and then the form will fill in the "type ID" into a text box.
 
To retrieve a value from a combo or list, you might use the column property of the control, if you're not referring to the bound column.

For instance the following would populate a text control with the second column of a combo named cboTest (they are zero based)

[tt]Me!txtBox.Value = Me!cboTest.Column(1)[/tt]

and the following would populate a text control with what's in the bound column of the combo

[tt]Me!txtBox.Value = Me!cboTest.Value[/tt]

Roy-Vidar
 
Ok, I've tried doing this to no avail: I go into the event procedure for the combo box that I want to update from and I put in the following code:

Private Sub AnalyteIDBox_AfterUpdate()
Me!AnalyteName.Value = Me!AnalyteIDBox.Column(1)
End Sub

But now when I try to run the form and select the value from the combo box and have it put the corresponding column two value into the text box I get this error:

A problem occurred while ACGP Database was communicating with the OLE server or ActiveX Control

Close the OLE server and restart it outside of the ACGP Database. Then try the original operation again in ACGP Database.

And then after I click OK on that error I get this one:
*The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro

Thats all the information it gives me. I've compiled the "code" for my database and it doesn't give me any errors. What gives?
 
Don't really know, as long as the control names are correct, I don't see anything wrong with the code.

A quick search revealed some info on the first error, for instance faq181-2843 (corruption?), Help -- getting crazy error message! (again, corruption) or A problem occurred while Microsoft Access was communicating with the OLE Server" error message when you embed or link a Word document (Norton Antivirus)

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top