On Error GoTo Err_Form_DblClick
DoCmd.OpenForm "SelectAffected", acNormal, , "[HazardID] = " & Me.HazardID
'
'If Not Me.NewRecord Then
' DoCmd.OpenForm "SelectAffected", _
' WhereCondition:="HazardID=" & Me.HazardID 'Vlad: So if you are in an Existing record open SelectedAffected on thhis record -already opened by previous Docmd.OpenForm line
'End If
' If Me.Form.CurrentRecord = Me.Form.RecordsetClone.RecordCount Then 'Vlad: if you are on the last record close the form and save design changes
' DoCmd.Close acForm, "HazardList", acSaveYes 'Vlad: acSaveYes saves design changes for the form, not the form's data
' Else
Dim rs As DAO.Recordset, h, t
With Me
Set rs = .RecordsetClone
rs.Bookmark = .Bookmark
rs.MoveNext
If Not rs.EOF Then 'If not last record
.Bookmark = rs.Bookmark
Else
'last record
Set rs = Nothing
DoCmd.Close acForm, "HazardList"
End If
Set rs = Nothing
End With
' DoCmd.GoToRecord Record:=acNewRec 'Vlad: if you are on any other record then last open a new record on SelectedAffected form as that is the one with the focus
' DoCmd.GoToRecord Record:=Me.NewRecord
'End If
Exit_Form_DblClick:
Exit Sub
Err_Form_DblClick:
MsgBox Err.Description & " " & Err.Number
Resume Exit_Form_DblClick