Do you wsh to save changes, drop or cancel?

  • Thread starter Alastair MacFarlane
  • Start date
A

Alastair MacFarlane

Dear All,

I have created a after_update event on a Yes/No CheckBox which searches
through a recordset clone of the form and updates related records. When I run
the code below, which works, I get the message: "Another user has made
changes to the record. Do you wsh to save changes, drop or cancel?" How can I
ensure that this message does not pop up?

I understand why this message appears but not how to stop it from appearing?

Private Sub Include_AfterUpdate()
Dim rst As DAO.Recordset
Dim bvBookmark As String
Dim SearchCriteria As String
If Me!Include = True Then
bvBookmark = Me.Bookmark
Set rst = Me.RecordsetClone
With rst
.MoveFirst
SearchCriteria = "[FirstNames] = '" & Me!FirstNames & "' And
[LastName] = '" & Me![LastName] & "'"
.FindFirst SearchCriteria
Do Until .NoMatch
.Edit
!Include = True
.Update
.FindNext SearchCriteria
Loop
End With
Set rst = Nothing
Me.Refresh
Me.Bookmark = bvBookmark
End If
End Sub
 
W

Wayne Morgan

Try an Update Query instead. It should also be faster than looping using
DAO.

Dim strSQL As String
strSQL = "UPDATE [" & Me.RecordSource & "] SET Include = True WHERE
[FirstNames] = '" & Me!FirstNames & "' And [LastName] = '" & Me![LastName] &
"';"
CurrentDb.Execute strSQL, dbFailOnError

Also, in your search criteria, you are using single quotes as delimiters
since you are checking for string values. This will work as long as none of
the data has an apostrophe in it, such as the last name O'Hare. If this is a
possibility, change each single quote to double double quotes (""), it's a
little harder to read, but will work.
 

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