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

Automatically populate field value based on a combo box selection.

Status
Not open for further replies.

murphy123

Technical User
Feb 18, 2006
41
0
0
US
Hello,
I've been trying to automatically populate the field value based on a combo box selection. I've looked for help in many postings and everything that I try simply doesn't work for me.

I have a couple of fields in a table that has ID numbers and all I need is their descriptions to automatically populate. I don't need to select more than one choice per combo box. Once data is collected it will be stored into a table. I am using a form to make these selections. My first combo box is a UserID box, which I need the very next field to populate the UserID Name. I will also have another combo box on the same form for Account#, then I need Account Name (this information is not in the User_IDs table.

For my first combo:
On the row source of the UserID I have the following code: SELECT [User_IDs].[UserID] FROM User_IDs ORDER BY [UserID];

Things that I have tried and hasn't worked so far, not sure what I am doing wrong. Tried on After Update, On Change, Click...

Private Sub UserIDs_AfterUpdate()

Me.User_Name = Me.UserIDs.Column(1)

End Sub

I don't how to create a column count if that's need.

Any help is greatly appreciated or other suggestions. I've spent a lot time reading through postings. Thanks all.
 

Perhaps...
Code:
Me.User_Name = DLookup("User_Name", "Usur_IDs", "UserID = " & Me.User_ID)


Randy
 
Thanks Randy. I tried the code, but I'm getting an error msg.

"The expression you entered as a query parameter produced this error:" ...then it gives me the userID that I selected. The Name values are Null.

Any other suggestions?
 

Is your form bound to the table?
Which table? Field names, please.
Did you use the wizard to build your combo box?


Randy
 
Hi Randy,

Is your form bound to the table?
YES

Which table?
Field names, please.
The table where the User detail is:
LAN_IDs
Fields: UserName, UserID

Table where I need the data to be stored:
tblCredit
fields: CSC_ID, CSC_Name (there are several other fields)
The fields that I need to auto populate is called is CSC_Name.

The CSC_ID is the same as UserID from the LAN_IDs table.

Did you use the wizard to build your combo box?
I have used wizard. It didn't work and I also added the Unbound combo, which I wasn't able to make it work either.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top