Not In List

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top