Hello, I have a form that lists towns with a control named Reference Date. When I change the Reference Date, a message box appear, giving the choice to apply this date to every town, or just on the current one. My code works, but the problem I have is when I change town, I get a Writing conflict, asking me to Save, Copy to clipboard or cancel. When I click Save everything works fine, but I don't want this message box appearing everytime! I have this same problem in others forms, for the same reason.
Here's the code I use:
Private Sub txtRefDate_AfterUpdate()
Dim db As DAO.database
Dim rs As DAO.Recordset
Dim choice As Integer
choice = MsgBox("Do you want to apply this date to every town?", vbOKCancel)
If choice = 1 Then
Set db = CurrentDb
Set rs = db.OpenRecordset("Table_Town")
rs.MoveFirst
Do While Not rs.EOF
With rs
.Edit
!RefDate= Me.txtRefDate.value
.Update
.MoveNext
End With
Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End If
End Sub
Here's the code I use:
Private Sub txtRefDate_AfterUpdate()
Dim db As DAO.database
Dim rs As DAO.Recordset
Dim choice As Integer
choice = MsgBox("Do you want to apply this date to every town?", vbOKCancel)
If choice = 1 Then
Set db = CurrentDb
Set rs = db.OpenRecordset("Table_Town")
rs.MoveFirst
Do While Not rs.EOF
With rs
.Edit
!RefDate= Me.txtRefDate.value
.Update
.MoveNext
End With
Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End If
End Sub