Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / May 2007

Tip: Looking for answers? Try searching our database.

Combo box select

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jk - 19 May 2007 00:56 GMT
i have a two column combo box with one column for employee number and second
column for employee name. On the form both columns appear but i want to have
the employee number selected and the associated name appear in another text
box.How is this done?
Daniel - 19 May 2007 03:22 GMT
you could use the afterupdate event of the combo box to populate the text
box.  Something like,

If isnull(Me.ComboboxName)=False then
   Me.TextboxName = Me.ComboboxName.Column(1)
End if

An alternative would be to use dlookup to get the name based on the id.
Signature

Hope this helps,

Daniel P

> i have a two column combo box with one column for employee number and second
> column for employee name. On the form both columns appear but i want to have
> the employee number selected and the associated name appear in another text
> box.How is this done?
John W. Vinson - 19 May 2007 05:25 GMT
>i have a two column combo box with one column for employee number and second
>column for employee name. On the form both columns appear but i want to have
>the employee number selected and the associated name appear in another text
>box.How is this done?

A third selection, aside from Daniel's two, is to set the combo's Bound Column
property to the one you want stored (the ID); the column widths property can
be set to 0 for the ID if you don't want it visible.

Or, you can put a textbox on the form with a control source

=comboboxname.Column(n)

where n is the *zero based* index of the field you want to display - (1) to
show the second column.

            John W. Vinson [MVP]
Christy Wyatt - 21 May 2007 14:24 GMT
The two answers already provided will display the employee name, but if you
want the value to save in the field you can do something like this:

Private Sub cboEmpID_BeforeUpdate(Cancel As Integer)
Set rs = CurrentProject.Connection.Execute("select [EmpName] from Topics
where EmpID = '" & Me.EmpID.Value & "'")
Me.[EmpName] = rs("EmpName")
Set rs = Nothing
End Sub

End Sub
Signature

Christy Wyatt

> i have a two column combo box with one column for employee number and second
> column for employee name. On the form both columns appear but i want to have
> the employee number selected and the associated name appear in another text
> box.How is this done?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.