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

adding 2 seperate strings instead of one in combo box

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
US
I have a combo box that I am populating by a query. The problem is that when it reads the data from the database and it is seperated by a ",". like lastname, firstname it used the additem and adds the lastname and the first name as two seperate items. How can I get it to only add lastname, firstname exactly like that (i.e. smith, john) on the same row..

my code:

Dim db As Database
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
Dim strVAR As String
Dim stridowner As String
Dim X As Integer

If Me.cmbdatephase.Value = "January" Or Me.cmbdatephase.Value = "February" Or Me.cmbdatephase.Value = "March" Or Me.cmbdatephase.Value = "April" Or Me.cmbdatephase.Value = "May" Or Me.cmbdatephase.Value = "June" Or Me.cmbdatephase.Value = "July" Or Me.cmbdatephase.Value = "August" Or Me.cmbdatephase.Value = "September" Or Me.cmbdatephase.Value = "October" Or Me.cmbdatephase.Value = "November" Or Me.cmbdatephase.Value = "December" Then



Set cnn = CurrentProject.Connection
strSQL = "Select distinct txtidowner FROM NSAPLOG WHERE initialreviewphase='" & cmbdatephase.Value & "'"

Set rs = cnn.Execute(strSQL)

rs.MoveFirst

Do While Not rs.EOF

strVAR = rs.Fields(0).Value


rs.MoveNext
cmbowners.AddItem (strVAR)

Loop
rs.Close

Set rs = Nothing
Set cnn = Nothing
MsgBox "ID Owners retreived for reivew month: " & cmbdatephase.Value & ". Please select ID Owner from list and click send email reports button."

Else
MsgBox "Please select a Month to review."
End If
 
Set the [tt]Row Source Type[/tt] of the combo box to Table/Query and set the [tt]Row Source[/tt] to
[tt]SELECT Chr(34) & NameField & Chr(34) FROM TableName;[/tt]

This will add double quotes around the name so the combo box should treat each field as one item.

Hope this helps,
CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Play with the RowSourceType and RowSource properties of the ComboBox object instead of the AddItemm method (as already explained in your previous thread)...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top