D
Dave Elliott
Code does not work, Why ? My Control on form is named City and control
source is City with a lookup (i.e. Row Source) of City from City Query.
However the table name is Cities.
Thanks,
Dave
On Error GoTo CheckError
Dim msg As String, ctl As Control, intReply As Integer
Dim db As DAO.Database, rst As DAO.Recordset
Set ctl = Me!City
msg = "That City is not Listed." & vbCrLf & "Would you Like to Add it?"
intReply = MsgBox(msg, vbYesNo + vbQuestion, "Not in List")
If intReply = vbYes Then
Response = acDataErrAdded
Set db = CurrentDb
'Set rst = db.OpenRecordset("tblcities")
Set rst = db.OpenRecordset("cities") 'Changed "tblsongs" to "City" on
7/16/03.
With rst
.AddNew
'![Name Prefix] = NewData 'Add data.
![City] = NewData 'Add data. 'Changed "Name Prefix" to "City" on
7/16/03.
.Update 'Save changes.
.Close
End With
Else
Response = acDataErrContinue
ctl.Undo
End If
CleanUp:
Set rst = Nothing
Set ctl = Nothing
Set db = Nothing
Exit Sub
CheckError:
msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox msg, vbOKOnly + vbExclamation, "Error", Err.HelpFile, Err.HelpContext
GoTo CleanUp
source is City with a lookup (i.e. Row Source) of City from City Query.
However the table name is Cities.
Thanks,
Dave
On Error GoTo CheckError
Dim msg As String, ctl As Control, intReply As Integer
Dim db As DAO.Database, rst As DAO.Recordset
Set ctl = Me!City
msg = "That City is not Listed." & vbCrLf & "Would you Like to Add it?"
intReply = MsgBox(msg, vbYesNo + vbQuestion, "Not in List")
If intReply = vbYes Then
Response = acDataErrAdded
Set db = CurrentDb
'Set rst = db.OpenRecordset("tblcities")
Set rst = db.OpenRecordset("cities") 'Changed "tblsongs" to "City" on
7/16/03.
With rst
.AddNew
'![Name Prefix] = NewData 'Add data.
![City] = NewData 'Add data. 'Changed "Name Prefix" to "City" on
7/16/03.
.Update 'Save changes.
.Close
End With
Else
Response = acDataErrContinue
ctl.Undo
End If
CleanUp:
Set rst = Nothing
Set ctl = Nothing
Set db = Nothing
Exit Sub
CheckError:
msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox msg, vbOKOnly + vbExclamation, "Error", Err.HelpFile, Err.HelpContext
GoTo CleanUp