|
-
Jul 18th, 2006, 06:21 PM
#1
Thread Starter
Lively Member
Load second combo box
This code works for first combo box. How would I populate the second box on the form load? Thanks!
Private Sub Form_Load()
Dim lrs As ADODB.Recordset
Set m_con = New ADODB.Connection
Call m_con.Open("DRIVER={SQL Server};SERVER=(LOCAL);UID=Cust;PWD=aaa")
If m_con.State = adStateOpen Then
Set lrs = New ADODB.Recordset
Set lrs.ActiveConnection = m_con
lrs.CursorLocation = adUseClient
lrs.CursorType = adOpenStatic
Call lrs.Open("SELECT * FROM Talk..ProgramsOffered")
Call LoadCombo(cmbProgram, lrs, "ProgramName", "ProgramKeyField")
If cmbProgram.ListCount > 0 Then
cmbProgram.ListIndex = 0
End If
End If
Second ComboBox Info:
Call lrs2.Open("SELECT * FROM Talk.._UserName ORDER BY SortSeq")
Call LoadCombo(cmbUserName, lrs2, "UserName", "UserNameKey")
If cmbUserName.ListCount > 0 Then
cmbProgram.ListIndex = 0
End If
-
Jul 18th, 2006, 06:31 PM
#2
Re: Load second combo box
First of all, when you post code please put it inside VBCode tags - either using the button in the post editor screen, or by putting them in manually, like this: [vbcode] 'code here [/vbcode]
Also, when some code you have written isn't working, it's best to tell us why it isn't (such as any error messages that are shown).
Anyhoo, you appear to be missing these lines:
VB Code:
Set lrs2 = New ADODB.Recordset
Set lrs2.ActiveConnection = m_con
lrs2.CursorLocation = adUseClient
lrs2.CursorType = adOpenStatic
-
Jul 18th, 2006, 06:48 PM
#3
Thread Starter
Lively Member
Re: Load second combo box
Thanks, worked like a charm. I'll use the vb quotes next time as well as give the error.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|