M
m stroup
I have marked Limit to List as yes. I have entered the following code:
Private Sub cboCompany_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_cboCompany_NotInList
Dim NewCompany As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
If MsgBox("Would you like to add this company?") = vbNo Then
MsgBox ("Please enter a valid company from the drop down box.")
Else
'Open a new recordset in the Company table.
NewCompany = cboCompany.Text
Set db = CurrentDb
Set rs = db.OpenRecordset("tblCompanies", dbOpenDynaset)
rs.AddNew
rs![Company] = NewCompany
rs.Update
'Set cboCompany to NewCompany
cboCompany.Value = NewCompany
End If
Exit_cboCompany_NotInList:
Exit Sub
Err_cboCompany_NotInList:
MsgBox Err.Description
End Sub
I continue to get the 'the item is not on the list' message. Any suggestions?
Private Sub cboCompany_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_cboCompany_NotInList
Dim NewCompany As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
If MsgBox("Would you like to add this company?") = vbNo Then
MsgBox ("Please enter a valid company from the drop down box.")
Else
'Open a new recordset in the Company table.
NewCompany = cboCompany.Text
Set db = CurrentDb
Set rs = db.OpenRecordset("tblCompanies", dbOpenDynaset)
rs.AddNew
rs![Company] = NewCompany
rs.Update
'Set cboCompany to NewCompany
cboCompany.Value = NewCompany
End If
Exit_cboCompany_NotInList:
Exit Sub
Err_cboCompany_NotInList:
MsgBox Err.Description
End Sub
I continue to get the 'the item is not on the list' message. Any suggestions?