WILDDUSTIE
04-09-2017, 06:10 PM
I am relatively new to programming and have an issue I can't seem to overcome. I'm creating a user form and two comboboxes are required. I need them to populate by reading from two separate access tables. Here is what I have so far:
Private Sub UserForm_Initialize()
Dim dbConnection As Object
Dim recordSet As Object
Dim strSQL As String
Dim strConnectionConfig As String
Set dbConnection = CreateObject("ADODB.Connection")
strConnectionConfig = "Provider=Microsoft.ACE.OLEDB.12.0;" _
& "Data Source = ASSIGNMENT 4.accdb;"
dbConnection.Open (strConnectionConfig)
strSQL = "SELECT DISTINCT DOCTORID FROM DOCTOR"
Set recordSet = dbConnection.Execute(strSQL)
SETAPPTUF.DRIDCB.AddItem ("ALL")
Do While (Not recordSet.EOF)
SETAPPTUF.DRIDCB.AddItem (recordSet("DOCTORID"))
recordSet.MoveNext
Loop
strSQL = "SELECT DISTINCT PATIENTID FROM PATIENT"
Set recordSet = dbConnection.Execute(strSQL)
SETAPPTUF.PTIDCB.AddItem ("ALL")
Do While (Not recordSet.EOF)
SETAPPTUF.PTIDCB.AddItem (recordSet("PATIENTID"))
recordSet.MoveNext
Loop
End Sub
Any help is appreciated.
Private Sub UserForm_Initialize()
Dim dbConnection As Object
Dim recordSet As Object
Dim strSQL As String
Dim strConnectionConfig As String
Set dbConnection = CreateObject("ADODB.Connection")
strConnectionConfig = "Provider=Microsoft.ACE.OLEDB.12.0;" _
& "Data Source = ASSIGNMENT 4.accdb;"
dbConnection.Open (strConnectionConfig)
strSQL = "SELECT DISTINCT DOCTORID FROM DOCTOR"
Set recordSet = dbConnection.Execute(strSQL)
SETAPPTUF.DRIDCB.AddItem ("ALL")
Do While (Not recordSet.EOF)
SETAPPTUF.DRIDCB.AddItem (recordSet("DOCTORID"))
recordSet.MoveNext
Loop
strSQL = "SELECT DISTINCT PATIENTID FROM PATIENT"
Set recordSet = dbConnection.Execute(strSQL)
SETAPPTUF.PTIDCB.AddItem ("ALL")
Do While (Not recordSet.EOF)
SETAPPTUF.PTIDCB.AddItem (recordSet("PATIENTID"))
recordSet.MoveNext
Loop
End Sub
Any help is appreciated.