Does anyone know how to two combo boxes with two list boxes.
The first combobox would bring up address table from address recordset, which you select
from and in list box, it will bring up phone numbers from phone recordset.
The second combobox would bring up same address table from address recordset, which
you select from, but in this list box, it will bring up email numbers from email recrodset.
I can get the first one working fine, but don't know how to write so I can pick up the
emails in second one.
Thank you.
Below is portion of code:
Private Sub Combo1_Click()
rsAddress.Find "AddressID = '" & _
Combo1.Text & "'", , , 1
LoadAddressInfo
List1.Clear
prmAddressID.Value = rsAddress!AddressID
Set rsPhone = cmdPhone.Execute
If rsPhone.RecordCount > 0 Then
LoadListBox1
Else
MsgBox "Not found"
End If
End Sub
Private Sub Combo2_Click()
rsAddress.Find "AddressID = '" & _
Combo2.Text & "'", , , 2
LoadAddressInfo
List2.Clear
prmAddressID.Value = rsAddress!AddressID
Set rsEmail = cmdEmail.Execute
If rsEmail.RecordCount > 0 Then
LoadListBox2
Else
MsgBox "Not found"
End If
End Sub
Private Sub LoadListBox1()
Dim intRecordCnt As Integer
For intRecordCnt = 1 To rsPhone.RecordCount
List1.AddItem rsPhone!ConnectType
rsPhone.MoveNext
Next intRecordCnt
rsPhone.MoveFirst
End Sub
Private Sub LoadListBox2()
Dim intRecordCnt As Integer
For intRecordCnt = 1 To rsEmail.RecordCount
List2.AddItem rsEmail!ConnectType
rsEmail.MoveNext
Next intRecordCnt
rsEmail.MoveFirst
End Sub
THE FOLLOWING PORTION, i DON'T KNOW HOW TO ADD SO IT PICKS UP SECOND
COMBO AND LIST..............
Private Sub Form_Initialize()
Set cnLynnPhonebook = New Connection
Set rsAddress = New Recordset
Set rsPhone = New Recordset
Set cmdPhone = New Command
Set rsEmail = New Recordset 'added
Set cmdEmail = New Command 'added
cnLynnPhonebook.CursorLocation = adUseClient
cnLynnPhonebook.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\WINDOWS\Desktop\LynnnLastClass\LynnPhonebook.mdb;Persist Security
Info=False"
rsAddress.Open "Select * FROM Address", _
cnLynnPhonebook, adOpenStatic, adLockOptimistic, adCmdText
cmdPhone.ActiveConnection = cnLynnPhonebook
cmdPhone.CommandText = "SELECT * FROM Phone " _
& "WHERE AddressID = ?"
cmdPhone.CommandType = adCmdText
Set prmAddressID = cmdPhone.CreateParameter("ID", adChar, adParamInput, 20)
cmdPhone.Parameters.Append prmAddressID
LoadAddressInfo
End Sub
Private Sub Form_Load()
With rsAddress 'with is more efficient structure
Do Until .EOF
Combo1.AddItem !AddressID
'Combo2.AddItem !AddressID 'added
.MoveNext
Loop
.MoveFirst
Combo1.Text = !AddressID
'Combo2.Text = !AddressID ' added
End With
LoadAddressInfo
End Sub