Last record problem, is it really the last record?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have this code on a button that when pressed copies the data from the field
'run_waypoint' (based on a combo box) from each record on the source form to
a set of sequential fields [GetRound_#] on the target form. All works ok,
except that the code always goes one extra step and copies the "," comma from
the last field string. It's as if the last source record isn't really what it
seems...


I have tried using these two code snippets to register either the end of
records or the last empty field, but neither method seems to stop this
happening?, can someone help me solve this problem? What am I doing wrong?

If Me.Recordset.EOF = True Then
MsgBox "cannot go to next record"
Else
DoCmd.GoToRecord , , acNext
End If



If Me.CurrentRecord < Me.Recordset.RecordCount Then DoCmd.GoToRecord , ,
acNext


End If




MY CODE



Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_1] = Me.Run_waypoint
& ", " & Me.Postcode

If Me.Recordset.EOF = True Then
MsgBox "cannot go to next record"
Else
DoCmd.GoToRecord , , acNext
End If



Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_2] = Me.Run_waypoint
& ", " & Me.Postcode

If Me.Recordset.EOF = True Then
MsgBox "cannot go to next record"
Else
DoCmd.GoToRecord , , acNext
End If

Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_3] = Me.Run_waypoint
& ", " & Me.Postcode

If Me.Recordset.EOF = True Then
MsgBox "cannot go to next record"
Else
DoCmd.GoToRecord , , acNext
End If



Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_4] =
Me.Run_waypoint & ", " & Me.Postcode

If Me.Recordset.EOF = True Then
MsgBox "cannot go to next record"
Else
DoCmd.GoToRecord , , acNext
End If



Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_5] = Me.Run_waypoint
& ", " & Me.Postcode

If Me.Recordset.EOF = True Then
MsgBox "cannot go to next record"
Else
DoCmd.GoToRecord , , acNext
End If
 
I HAVE NOW SOLVED THIS PROBLEM...

The answer was to keep it simple and rewrite the code:

If IsNull(Me.[Run_waypoint]) Then
End
Else
Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_1] = Me.Run_waypoint &
", " & Me.Postcode
DoCmd.GoToRecord , , acNext
End If


If IsNull(Me.[Run_waypoint]) Then
'MsgBox "TEST cannot go to next record"
End
Else
Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_2] = Me.Run_waypoint &
", " & Me.Postcode
DoCmd.GoToRecord , , acNext
End If


If IsNull(Me.[Run_waypoint]) Then
'MsgBox "TEST cannot go to next record"
End
Else
Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_3] = Me.Run_waypoint &
", " & Me.Postcode
DoCmd.GoToRecord , , acNext
End If

If IsNull(Me.[Run_waypoint]) Then
'MsgBox "TEST cannot go to next record"
End
Else
Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_4] = Me.Run_waypoint &
", " & Me.Postcode
DoCmd.GoToRecord , , acNext
End If

efandango said:
I have this code on a button that when pressed copies the data from the field
'run_waypoint' (based on a combo box) from each record on the source form to
a set of sequential fields [GetRound_#] on the target form. All works ok,
except that the code always goes one extra step and copies the "," comma from
the last field string. It's as if the last source record isn't really what it
seems...


I have tried using these two code snippets to register either the end of
records or the last empty field, but neither method seems to stop this
happening?, can someone help me solve this problem? What am I doing wrong?

If Me.Recordset.EOF = True Then
MsgBox "cannot go to next record"
Else
DoCmd.GoToRecord , , acNext
End If



If Me.CurrentRecord < Me.Recordset.RecordCount Then DoCmd.GoToRecord , ,
acNext


End If




MY CODE



Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_1] = Me.Run_waypoint
& ", " & Me.Postcode

If Me.Recordset.EOF = True Then
MsgBox "cannot go to next record"
Else
DoCmd.GoToRecord , , acNext
End If



Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_2] = Me.Run_waypoint
& ", " & Me.Postcode

If Me.Recordset.EOF = True Then
MsgBox "cannot go to next record"
Else
DoCmd.GoToRecord , , acNext
End If

Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_3] = Me.Run_waypoint
& ", " & Me.Postcode

If Me.Recordset.EOF = True Then
MsgBox "cannot go to next record"
Else
DoCmd.GoToRecord , , acNext
End If



Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_4] =
Me.Run_waypoint & ", " & Me.Postcode

If Me.Recordset.EOF = True Then
MsgBox "cannot go to next record"
Else
DoCmd.GoToRecord , , acNext
End If



Forms.frm_Runs.[frm_Getround_MapMaker].Form.[GetRound_5] = Me.Run_waypoint
& ", " & Me.Postcode

If Me.Recordset.EOF = True Then
MsgBox "cannot go to next record"
Else
DoCmd.GoToRecord , , acNext
End If
 
Back
Top