***** snip *******
If you notice anything out of order please advise.
***** snip *******
Rick,
I've been following your thread; I looked at the code and added some
comments. These are only my opinion - no criticism intended (The MVP's
would probably take away my keyboard if they looked at some of my coding
<g>)
This looked better in the IDE - the comments were in green
'****** begin code ***********
Private Sub UpdateAll_Click()
Dim frmRst As DAO.Recordset
Dim i As Integer
Dim msg As String '*** Added
Dim btns As Long '*** Added
'These can be deleted - they are not used
'Dim myform As Form
'Dim r As Integer
'Set myform = Me.GroupMembers.Form
'r = frmRst.RecordCount
Set frmRst = Me.GroupMembers.Form.Recordset
On Error GoTo Err_NextRecord
' this just makes the code easier to read
msg = "Are you sure you wish to update ALL family member's data?" _
& vbCr & vbCr & "If you continue all data for each family
member will be reset to" _
& vbCr & "match the data entered in the top screen." & vbCr &
vbCr _
& "Any blank fields in the top screen will NOT overwrite
existing " & vbCr & _
"data for any family member below."
'*** Added - easier to see what buttons are used
btns = vbDefaultButton2 + vbCritical + vbYesNo
If MsgBox(msg, btns, CurrentUser()) = vbNo Then ' vbNo = 7 ****
'You can't cancel the Click event *****
'Cancel = True
Exit Sub
End If
frmRst.MoveFirst
'***CHANGED
' moved "WITH frmRst...END WITH" outside the loop.
' Only have to resolve the reference once which is
'faster - not 23 times
With frmRst
Do While Not .EOF
For i = 1 To 23
If Me("Dat" & i) <> 0 Then
Forms!ContactProfile!GroupHead!GroupMembers.Form! _
("Cont" & i) = Me("Dat" & i)
End If
Next i
'if the code works then the next 2 lines are not needed
' and can be deleted. See the bottom of the code
'.Edit
'.Update
.MoveNext
Loop
End With
Exit_NextRecord:
'**** You can't cancel the Click event ***
'Cancel = True
Exit Sub
DoCmd.Close acForm, "GroupHead"
Err_NextRecord:
Response = acDataErrContinue
'*** CHANGED the following IF()
If Err.Number = 3021 Then
Resume Exit_NextRecord
ElseIf Err.Number = 3020 Then
'**** You can't cancel the Click event ***
'Cancel = True
DoCmd.Close acForm, "GroupHead"
Else
MsgBox Err.Number & " " & Err.Description
End If
End Sub
'*********** end code ************
'Like Mike Painter posted, When using a DAO recordset,
' the fields in a record are changed like this:
With rs
.Edit
!FieldName1 = Me.Textbox1OnForm
!DateField = Date
!UserNameField = CurrentUser()
.Update
End With
HTH