B
bryan
I have a user form which I populate using sql on a database with a variable
passed in. I display the results for selection in a combobox. What's
displayed is name and business type. Selection is returned for use. What I
also need to include in the sql is an id number for use as well in return
but, I do not want that displayed.
1) can I add the id into the combobox and not have it display or
2) how else can I accomplish this?
Here is what I have:
Public ClaimN As String
Private Sub UserForm_Activate()
strcharID = ClaimN
connection string>>>>>>
strquery1 = "Select entity_table_id, isnull(First_Name,'')as FN,
isnull(Last_Name,'')as LN, isnull(Contact,'')as MI, " & _
"States.State_ID " & _
"from Claimant_V cv left outer join " & _
"STATES on cv.State_ID = STATES.State_Row_ID " & _
"where cv.relation_sc like '%CL%' and cv.eff_end_date <>
cv.eff_start_date and cv.claim_id = '" + strcharID + "'"
Dim zd
Set zd = CreateObject("ADODB.Recordset")
zd.Open strquery1, objConn1, 2, 3
If Not zd.EOF Then
zd.MoveFirst
Do While Not zd.EOF
strty = Trim(zd("entity_table_id").Value)
strf = Trim(zd("FN").Value)
strL = Trim(zd("LN").Value)
strM = Trim(zd("MI").Value)
If strty = "1576" Then
strtp = "B"
Else
strtp = "I"
End If
If strf = "" Then
ComboBox1.AddItem strtp + " " + strL
Else
ComboBox1.AddItem strtp + " " + strf + " " + strL
End If
zd.MoveNext
Loop
ComboBox1.ListIndex = 0
End If
end sub
passed in. I display the results for selection in a combobox. What's
displayed is name and business type. Selection is returned for use. What I
also need to include in the sql is an id number for use as well in return
but, I do not want that displayed.
1) can I add the id into the combobox and not have it display or
2) how else can I accomplish this?
Here is what I have:
Public ClaimN As String
Private Sub UserForm_Activate()
strcharID = ClaimN
connection string>>>>>>
strquery1 = "Select entity_table_id, isnull(First_Name,'')as FN,
isnull(Last_Name,'')as LN, isnull(Contact,'')as MI, " & _
"States.State_ID " & _
"from Claimant_V cv left outer join " & _
"STATES on cv.State_ID = STATES.State_Row_ID " & _
"where cv.relation_sc like '%CL%' and cv.eff_end_date <>
cv.eff_start_date and cv.claim_id = '" + strcharID + "'"
Dim zd
Set zd = CreateObject("ADODB.Recordset")
zd.Open strquery1, objConn1, 2, 3
If Not zd.EOF Then
zd.MoveFirst
Do While Not zd.EOF
strty = Trim(zd("entity_table_id").Value)
strf = Trim(zd("FN").Value)
strL = Trim(zd("LN").Value)
strM = Trim(zd("MI").Value)
If strty = "1576" Then
strtp = "B"
Else
strtp = "I"
End If
If strf = "" Then
ComboBox1.AddItem strtp + " " + strL
Else
ComboBox1.AddItem strtp + " " + strf + " " + strL
End If
zd.MoveNext
Loop
ComboBox1.ListIndex = 0
End If
end sub