Next button - error when arrived at end of records

G

Gina

Hi.

Could I make sure somehow that, when a user clicks the NEXT button, and the
recordset has arrived at the end EOF, that the next button doesn't offer the
option of going to a new empty record.

For now a user triggers an error message saying that null values arn't
allowed (guess from table def)

If the user wants to specifically create a new record a NEW button should be
pressed. That way I can make sure that no nonsense is saved to the db.
Here's the (standard) code for the next button. would I need to add sth.

_______________________________________
Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Click

DoCmd.GoToRecord , , acNext

Exit_cmdNext_Click:
Exit Sub

Err_cmdNext_Click:
MsgBox Err.Description
Resume Exit_cmdNext_Click

End Sub
________________________________________

Many thanks,
Gina
 
G

Guest

Hi Gina


Drop the following into your form:


Private Sub Form_Current()

Me.First.Enabled = (Me.CurrentRecord > 1)
Me.Previous.Enabled = (Me.CurrentRecord > 1)
Me.RecordsetClone.MoveLast
Me.Next.Enabled = (Me.CurrentRecord < Me.RecordsetClone.RecordCount)
Me.Last.Enabled = (Me.CurrentRecord < Me.RecordsetClone.RecordCount)

End Sub

You will have to change the name to match your button names. This will
control the movement between the records and prevent the user from moving to
a blank record.

Cheers
 
G

Gina

Thanks, Paul.

Unfortunately it doesn't work ... it doesn't jump into the Form_Current
event at all.... why ??
the buttons I am talking about are on that (current) form

Seems to be not an easy problem ?
Nevertheless must be a common one
What else I could try?? to get it done

Gina
 
G

Gina

Hi Paul.

I did click on the form, which is a subform in a subform of a main form
.... do you think it has sth. to do with it ?

Gina
 
G

Gina

Paul,
your code gave me quite a few ideas ... if not in the form current event
maybe somewhere else

that's what i've got now ... it works

______________________________________________________
NEXT

If Me.CurrentRecord >= 1 Then
If (Me.CurrentRecord < Me.RecordsetClone.RecordCount) Then
DoCmd.GoToRecord , , acNext
End If
End If


PREVIOUS

If Me.CurrentRecord > 1 Then
If (Me.CurrentRecord <= Me.RecordsetClone.RecordCount) Then
DoCmd.GoToRecord , , acPrevious
End If
End If

________________________________________________________

big big thanks .... now my beta can go out!!
Gina :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Detect if 1st Record 1
Next record button 3
Navigation Buttons 7
Navigation buttons 2
Next button problem 2
next buton NOT NEW 6
Inputing Data from one form to another 3
Next Record in Query Results via Form 4

Top