?
Solved

Getting value in a combobox based another combo.

Posted on 2006-04-26
1
Medium Priority
?
146 Views
Last Modified: 2011-09-20
How can I populate the combo2 from the value in combo1 both of these values are obtained from database. The following code is suppsed to do it however the program doesnt read this code when I change the selection in combo1

Private Sub CmbState_Change()   <---Is this the right function name?
Dim conn
Dim rec
Dim myvalue

myvalue = Me.CmbState.Text

Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Database.mdb;Persist Security Info=False"
esql = "select BAT from Dataset where STATE = " & myvalue & ";"
rec.Open (esql), conn, adOpenStatic, adLockReadOnly
If rec.RecordCount > 0 Then
   rec.MoveFirst
    Do Until rec.EOF
        FacilitySelection.CmbBat.AddItem rec("STATE")
        rec.MoveNext
    Loop
End If
conn.Close
Set conn = Nothing

End Sub
0
Comment
Question by:Aiysha
1 Comment
 
LVL 4

Accepted Solution

by:
g_johnson earned 2000 total points
ID: 16546965
that's not the right event.  change occurs when you type in the text portion

i would put it in the click event which occurs when you click in the list
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question