A
Andrew Smith
I have the following code in the NotInList event of a combo box. I'm sure
this used to work, but tonight I'm getting the default Access error message
appearing after the code runs. The code does successfully add the new data
to the table, but fails to refresh the combo box. This is in Access 2002
Any ideas?
Private Sub cboCompanyName_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rst As DAO.Recordset
If MsgBox("Do you want to add " & NewData, vbYesNo) = vbYes Then
Set db = CurrentDb
Set rst = db.OpenRecordset("tblCompanies")
With rst
.AddNew
!CompanyName = NewData
!Ticker = InputBox("Ticker for " & NewData, "Ticker")
.Update
.Close
End With
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
this used to work, but tonight I'm getting the default Access error message
appearing after the code runs. The code does successfully add the new data
to the table, but fails to refresh the combo box. This is in Access 2002
Any ideas?
Private Sub cboCompanyName_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rst As DAO.Recordset
If MsgBox("Do you want to add " & NewData, vbYesNo) = vbYes Then
Set db = CurrentDb
Set rst = db.OpenRecordset("tblCompanies")
With rst
.AddNew
!CompanyName = NewData
!Ticker = InputBox("Ticker for " & NewData, "Ticker")
.Update
.Close
End With
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub