I get an object required error when working with rstSubjectList from cmdAdd_Click. When I go to tracking mode from the command button, it says rstSubjectList = Nothing. It seems that the recordset is not being carried accross from the form_load, despite the two events being local to each other (they are in the same form). Please tell me how I can fix this error.
VB Code:
Private Sub Form_Load() Dim rstSubjectList As Recordset Set rstSubjectList = db.OpenRecordset("SELECT Subject FROM Subjects ORDER BY Subject") rstSubjectList.MoveFirst Do While Not rstSubjectList.EOF cboSubject.AddItem (rstSubjectList.Fields("Subject").Value) rstSubjectList.MoveNext Loop End Sub Private Sub cmdAdd_Click() With rstSubjectList 'Add subject if it doesn't already exist .FindFirst "Subject ='" & cboSubject.Text & "'" If .NoMatch = True Then .AddNew .Fields("Subject").Value = cboSubject.Text .Update End If End With


Reply With Quote
