L
Lez
Hi Guys,
I have added this code to a combo I have and keep getting an error message,
can anyone tell me whats wrong with this code please
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not an available CITY " & vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to associate the new CITY to the current
List?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to link or No to re-type
it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add New Source?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblcity", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Source = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End If
I have added this code to a combo I have and keep getting an error message,
can anyone tell me whats wrong with this code please
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not an available CITY " & vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to associate the new CITY to the current
List?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to link or No to re-type
it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add New Source?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblcity", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Source = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End If