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

Display full name after selecting id from combo 4

Status
Not open for further replies.

mtre

MIS
Jul 29, 2003
2
0
0
US
I am relatively new to access and am having trouble getting this to work. I did it before in school but can't seem to make it happen now. I have a form where the user selects a user id from a combo box. The combo has the user id in column 1, and the username in column 2so that the user can see the name when selecting the proper id. When the user selects the id, the id is diplayed in the combo box. What I want to do is have the user name display in an unbound text box right next to the combo. The code I am using to this point is given below. This code is based off of a database I built in school but I can't get it to work for this application.:

Private Sub MANAGER_AfterUpdate()
'Dim strfilter As String
'Dim strID As String
'Dim strName As String

'strID = Me![MANAGER]

'strfilter = "[MANAGER] = " & intID
'strName = DLookup("[APDisplay]", "dbo_MANAGER", strfilter)

'Me![NewText1] = strName
End Sub
 
Hi

No need for any code, in the source of the unbound text box put =MANAGER.Column(1)

If you are strting out, can I suggest you start on the right path, and use a naming convention:

eg cboMANAGER

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
You don't really need any code at all. I've got this expression in the "Data" property for a text box in one of my forms:

=[mycombo].[Column](1)

mycombo is the combo box. When you select a value in the combo box, it displays the second column value in the text box (the first column is "0").

It will update automatically every time you change the combo box value. It looks like your combo box is named "Manager", so your expression would be:

=[Manager].[Column](1)

 
Works like a charm!! Thanks to both you guys. I never knew about about this feature and you both saved me from even more hours of headbanging. Thanks again.
 
How are ya mtre . . . . .

You can also set the column width for the ID to zero and just display the name(the ID is still there).

Note: for a combobox, the display begins with the first non-zero column width. If you've ever used a lookup table or query generated by a wizard, you'll find thats exactly what they do.
 
Hi !
I have altered little in this.
I am displaying names in combo box and want to display surname and age. It works fine.

I have bound the text box to respective fields in table.
I am facing one problem with that.
When I first open the form the combo box displays the last selected value but other text boxes give details of my 1st record. How's that ?

Is it possible to display last record by default ?

can you reply ?

Thanks.
Apoorva
 
To KenReay and GDGarth,

Thank you both I was trying like heck to figure this out. Can't believe it was so simple. Thank you.

Neowynds
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top