R
RFrechette
Hi All,
Thanks to this forum I am using the code below to loop through a recordset.
In the first “If†statement within the loop: it assigns values based on the
date. In the second “If†statement: if the date is outside of a certain
range, a message appears and the code should move to after the loop.
I think I need a “Break†statement in there just before the 2nd “End Ifâ€
statement, but I don’t know the syntax and I’m not even sure if “Break†is
actually what I should use. I tried to use a “GoTo StopCode†then put
“StopCode:†before the “End Sub†but that just froze the application.
Dim RsC As DAO.Recordset
Set RsC = Me.RecordsetClone
RsC.MoveFirst
While Not RsC.EOF
Me.Bookmark = RsC.Bookmark
If [DATE] = [Forms]![frm_PVD]![tbl_PVD_subform].Form![PVD_Date] Then
Chk_Add = -1
Me![ID_oss_tran] = [Forms]![frm_PVD]![tbl_PVD_subform].Form![ID]
End If
If [Forms]![frm_PVD]![tbl_PVD_subform].Form![PVD_Date] <
DLookup("[BeginDate]", "dbo_oss_vhb_Data_Input") _
Or [Forms]![frm_PVD]![tbl_PVD_subform].Form![PVD_Date] >
DLookup("[EndDate]", "dbo_oss_vhb_Data_Input") Then
MsgBox "This record is out of the period date range.", vbOKOnly
'********************
'Break; ????
'********************
End If
RsC.MoveNext
Wend
Me.Requery
Set RsC = Nothing
I hope I explained this clear enough, any help will be much appreciated.
Thanks,
Rachel
Thanks to this forum I am using the code below to loop through a recordset.
In the first “If†statement within the loop: it assigns values based on the
date. In the second “If†statement: if the date is outside of a certain
range, a message appears and the code should move to after the loop.
I think I need a “Break†statement in there just before the 2nd “End Ifâ€
statement, but I don’t know the syntax and I’m not even sure if “Break†is
actually what I should use. I tried to use a “GoTo StopCode†then put
“StopCode:†before the “End Sub†but that just froze the application.
Dim RsC As DAO.Recordset
Set RsC = Me.RecordsetClone
RsC.MoveFirst
While Not RsC.EOF
Me.Bookmark = RsC.Bookmark
If [DATE] = [Forms]![frm_PVD]![tbl_PVD_subform].Form![PVD_Date] Then
Chk_Add = -1
Me![ID_oss_tran] = [Forms]![frm_PVD]![tbl_PVD_subform].Form![ID]
End If
If [Forms]![frm_PVD]![tbl_PVD_subform].Form![PVD_Date] <
DLookup("[BeginDate]", "dbo_oss_vhb_Data_Input") _
Or [Forms]![frm_PVD]![tbl_PVD_subform].Form![PVD_Date] >
DLookup("[EndDate]", "dbo_oss_vhb_Data_Input") Then
MsgBox "This record is out of the period date range.", vbOKOnly
'********************
'Break; ????
'********************
End If
RsC.MoveNext
Wend
Me.Requery
Set RsC = Nothing
I hope I explained this clear enough, any help will be much appreciated.
Thanks,
Rachel