T
Tony Williams
I have a combobox on a form where the values come from a table. I have the
columns limited to 1 and the bound column is 1. Here is my code for the
NotinList Event:
Private Sub Force_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not an available Value."
strMsg = strMsg & " Do you want to add the new Value to the current
List?"
strMsg = strMsg & " Click Yes to Add or No to re-type it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("RecoveryForce", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!RecoveryForce = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
Set db = Nothing
Set rs = Nothing
End Sub
I use this code on a number of comboboxes on my form but for some reason
that I cannot find when I try to add a value to this list I get the "An
error occurred. Please try again." message.
The database is split and the tables are in an mde file.
Can anyone see what could be wrong?
Thanks
Tony
columns limited to 1 and the bound column is 1. Here is my code for the
NotinList Event:
Private Sub Force_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not an available Value."
strMsg = strMsg & " Do you want to add the new Value to the current
List?"
strMsg = strMsg & " Click Yes to Add or No to re-type it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("RecoveryForce", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!RecoveryForce = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
Set db = Nothing
Set rs = Nothing
End Sub
I use this code on a number of comboboxes on my form but for some reason
that I cannot find when I try to add a value to this list I get the "An
error occurred. Please try again." message.
The database is split and the tables are in an mde file.
Can anyone see what could be wrong?
Thanks
Tony