Question about combo box data into text boxes (1 Viewer)

hammerva

Registered User.
Local time
Today, 13:04
Joined
Dec 19, 2000
Messages
102
Hello again. :)

I was brainstorming an idea for one of my screens in an application. I want to create a combo box of names and a text box. Whenever the user selects a name from the combo box it adds to the text box. The user can select as many names as possible with each one being added to the text box.

What event could I do this in? I figure the click event would work but does it only work when they doubleclick a name or click on the name? Also if they start typing in a name and the rest of the name appears because it is on the list, what event is activiated there?

Thanks
 

tacieslik

Registered User.
Local time
Today, 13:04
Joined
May 2, 2001
Messages
244
Will the text boxes value be over written each time they choose a new name? If so, could you just bind the text box to the combo?

Textbox Control Source: =[cmbNameOfCombo].Column(0)

You need to adjust the number in the brakets to match the column of the underlying table that the combo gets its data from. Zero is the first column.

Hope this helps!
Tim Cieslik
 

dcx693

Registered User.
Local time
Today, 08:04
Joined
Apr 30, 2003
Messages
3,265
Use the After Update event of the combo box, place some code in it like this:
Code:
Private Sub cboNames_AfterUpdate()
    If IsNull(Me.txtBox) Or Me.txtBox = "" Then
        Me.txtBox = Me.cboNames
    Else
        Me.txtBox = Me.txtBox & "," & Me.cboNames
    End If
End Sub
assuming your text box is called "txtBox" and your combo box is called "cboNames". It will produce a comma separated list of selections.
 
Last edited:

hammerva

Registered User.
Local time
Today, 13:04
Joined
Dec 19, 2000
Messages
102
Actually I was thinking more of adding to the text boxes. Chances are the user will have more than 1 name to process. So each time the user tried to click on a name it would be added to the Text box field.
 

dcx693

Registered User.
Local time
Today, 08:04
Joined
Apr 30, 2003
Messages
3,265
What exactly are you attempting to accomplish wiht the text box of names though?
 

hammerva

Registered User.
Local time
Today, 13:04
Joined
Dec 19, 2000
Messages
102
The text box will have the list of people attending meeting or review? I would rather have one text box than maybe 2 to any number of fields for each name possible
 

dcx693

Registered User.
Local time
Today, 08:04
Joined
Apr 30, 2003
Messages
3,265
The code I wrote above will give you a comman-delimited list of people. But do you then need to store that list or run a query based on that list or anything like that?
 

hammerva

Registered User.
Local time
Today, 13:04
Joined
Dec 19, 2000
Messages
102
Well right now I was thinking of just storing it in a text field. So the data would look something like:

"Hammond, Mike; Blow, Joe; Doe, Jane"
 

dcx693

Registered User.
Local time
Today, 08:04
Joined
Apr 30, 2003
Messages
3,265
OK, that code I have up there will work. Just replace the comma with a semi colon and add any spaces you want.

Of course, it's not the most efficient way of storing this data in a "relational" database, but storing it "correctly" would be much more complicated.
 

Users who are viewing this thread

Top Bottom