![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
i am opening a recordset in my VB code and populating a combo box with the data from one of the fields in my recordset. I want to set it up so that, when a user selects one of the values from the combo box, the text boxes on the form will be populated with the associated data. This is driving me insane! I've researched almost all day on this, and can't seem to find an answer. Any help would would be HUGELY appreciated as this is part of a project for the pres of our company...... Public dbMyDB As DAO.Database Public rsMyRS As DAO.Recordset Public MySQL1 As String Public Sub Form_Load() MySQL1 = "SELECT DISTINCT (calc.Employee_Number) AS empnum, " & _ "sum(calc.total) AS totalearned, sum(redpts.points_redeemed) AS used, " & _ "calc.Last_Name AS lname, calc.First_Name AS fname " & _ "FROM Calculation AS calc LEFT JOIN Redeemed_Points AS redpts " & _ "ON calc.Employee_Number=redpts.Employee_Number " & _ "GROUP BY calc.Employee_Number, calc.Last_Name, calc.First_Name" Set dbMyDB = CurrentDb() Set rsMyRS = dbMyDB.OpenRecordset(MySQL1, dbOpenDynaset) If Not rsMyRS.EOF Then rsMyRS.MoveFirst Do While Not rsMyRS.EOF cmbEmpNum.AddItem rsMyRS!empnum ' cmbEmpNum.ItemData(cmbEmpNum.NewIndex) = rsMyRS!empnum 'This line throws an error rsMyRS.MoveNext Loop End Sub Private Sub cmbEmpNum_Click() rsMyRS.FindFirst "empnum= '" & Str(cmbEmpNum.Value) & "'" 'These will populate, but only with the data from the 1st record regardless of the cmbEmpNum value txtLastName = rsMyRS!lname txtFirstName = rsMyRS!fname End Sub |
#3
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |