G
Guest
Does anyone know how I can make this code trap for the Last Record
The procedure cycles through a number of the same selection box on one
continuous form, and if the choice is correct, then copies the data to
another field on the target field/form. Then moves to the next selection,
until it fills in the last blank field record, that’s where it bombs out with
a no next record error: At the moment I have a quick fix in the shape of an
On Error line, but it’s not ideal as It realies on a natural error rather
than clean elegant code. I have tried every which way to get my head round
this, but have got nowhere for nearly 3 days.
Private Sub Waypoint_Selector_Click()
'~~~~~~~~~~~~~~~~~~~~~~
'set up Error Handler
On Error GoTo Proc_Err
'~~~~~~~~~~~~~~~~~~~~~~
If IsNull(Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo]) Then
Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Me.Waypoint_Selector
'If the Target field is empty then place the Selection from the Selector
Form into the Target Field on Target Form
End If
If (Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] <>
Forms.Runs.[frm_Run_Test].Form.[Run_waypoint]) Then
Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Null
'This checks if the selection is wrong, if so, then reset (blank) the
Waypoint Target
End If
If (Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] =
Forms.Runs.[frm_Run_Test].Form.[Run_waypoint]) Then
Parent.frm_Run_Test.SetFocus
Parent.frm_Run_Test.Form.Waypoint_Combo.SetFocus
DoCmd.GoToControl "Direction_Combo"
RunCommand acCmdRecordsGoToNext
'This sets the Focus back to the Run Test Form/Direction Control
End If
Proc_Err:
'MsgBox "All fields are filled"
End Sub
The procedure cycles through a number of the same selection box on one
continuous form, and if the choice is correct, then copies the data to
another field on the target field/form. Then moves to the next selection,
until it fills in the last blank field record, that’s where it bombs out with
a no next record error: At the moment I have a quick fix in the shape of an
On Error line, but it’s not ideal as It realies on a natural error rather
than clean elegant code. I have tried every which way to get my head round
this, but have got nowhere for nearly 3 days.
Private Sub Waypoint_Selector_Click()
'~~~~~~~~~~~~~~~~~~~~~~
'set up Error Handler
On Error GoTo Proc_Err
'~~~~~~~~~~~~~~~~~~~~~~
If IsNull(Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo]) Then
Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Me.Waypoint_Selector
'If the Target field is empty then place the Selection from the Selector
Form into the Target Field on Target Form
End If
If (Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] <>
Forms.Runs.[frm_Run_Test].Form.[Run_waypoint]) Then
Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Null
'This checks if the selection is wrong, if so, then reset (blank) the
Waypoint Target
End If
If (Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] =
Forms.Runs.[frm_Run_Test].Form.[Run_waypoint]) Then
Parent.frm_Run_Test.SetFocus
Parent.frm_Run_Test.Form.Waypoint_Combo.SetFocus
DoCmd.GoToControl "Direction_Combo"
RunCommand acCmdRecordsGoToNext
'This sets the Focus back to the Run Test Form/Direction Control
End If
Proc_Err:
'MsgBox "All fields are filled"
End Sub