Hi all,
In some of my forms i would like things such as combo boxes to retrieve their values using VBA code rather than them just being based upon an access query. My aim is replace all my access queries with just VBA. So far I am able to retrive values from the DB and put them into text boxes but am unsure of how i should i apply this to a combo box.
Say for example I wanted to select all the employees from my employee table and display them all in a combo box for the user to choose whichever one he/she wanted, would i go about it by doing this:
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
Dim myRecordSet As New ADODB.Recordset
myRecordSet.ActiveConnection = cnn1
Dim mySQL As String
mySQL = "SELECT EmployeeID, EmployeeFirstName, EmployeeLastName"
mySQL = mySQL + " FROM EmployeeTBL"
myRecordSet.Open mySQL
After this though I'm pretty unsure as to how i'd get the values into a combo box. If any one could help me here it would be very much appreciated,
Cheers
In some of my forms i would like things such as combo boxes to retrieve their values using VBA code rather than them just being based upon an access query. My aim is replace all my access queries with just VBA. So far I am able to retrive values from the DB and put them into text boxes but am unsure of how i should i apply this to a combo box.
Say for example I wanted to select all the employees from my employee table and display them all in a combo box for the user to choose whichever one he/she wanted, would i go about it by doing this:
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
Dim myRecordSet As New ADODB.Recordset
myRecordSet.ActiveConnection = cnn1
Dim mySQL As String
mySQL = "SELECT EmployeeID, EmployeeFirstName, EmployeeLastName"
mySQL = mySQL + " FROM EmployeeTBL"
myRecordSet.Open mySQL
After this though I'm pretty unsure as to how i'd get the values into a combo box. If any one could help me here it would be very much appreciated,
Cheers