Move next takes user to new record - not wanted 
Author Message
 Move next takes user to new record - not wanted

Hi,

I have put a button on a custom toolbar for move next and move previous, but
the move next allows the user to go past the last record onto a new record -
which I don't want.

I need a function that prevents this.  Had a go, but it doesn't seem to
work - can anyone tell me where I'm going wrong?

Cheers

Paul

Function movenext()

Dim frm As Form, rst As Recordset

Set frm = Screen.ActiveForm
Set rst = frm.RecordsetClone

If Not rst.EOF Then
DoCmd.GoToRecord , , acNext
End If

End function



Wed, 24 Sep 2003 02:26:56 GMT  
 Move next takes user to new record - not wanted
Assuming it's not enough just to set the form's AllowAdditions property to
False, you can probably use code like this:

'---- start of modified code ----
Function MoveNextRecord()

    Dim frm As Form

    Set frm = Screen.ActiveForm
    With frm
        If .CurrentRecord < .RecordsetClone.RecordCount Then
            DoCmd.GoToRecord , , acNext
        End If
    End With
    Set frm = Nothing

End Function
'---- end of modified code ----

I changed the function name so as to avoid possible confusion with the
MoveNext method.
--

Dirk Goldgar
(remove NOSPAM from reply address)


Quote:
> Hi,

> I have put a button on a custom toolbar for move next and move previous,
but
> the move next allows the user to go past the last record onto a new
record -
> which I don't want.

> I need a function that prevents this.  Had a go, but it doesn't seem to
> work - can anyone tell me where I'm going wrong?

> Cheers

> Paul

> Function movenext()

> Dim frm As Form, rst As Recordset

> Set frm = Screen.ActiveForm
> Set rst = frm.RecordsetClone

> If Not rst.EOF Then
> DoCmd.GoToRecord , , acNext
> End If

> End function



Wed, 24 Sep 2003 03:39:57 GMT  
 Move next takes user to new record - not wanted
Thanks Dirk - it's exactly what I needed.


Quote:
> Assuming it's not enough just to set the form's AllowAdditions property to
> False, you can probably use code like this:

> '---- start of modified code ----
> Function MoveNextRecord()

>     Dim frm As Form

>     Set frm = Screen.ActiveForm
>     With frm
>         If .CurrentRecord < .RecordsetClone.RecordCount Then
>             DoCmd.GoToRecord , , acNext
>         End If
>     End With
>     Set frm = Nothing

> End Function
> '---- end of modified code ----

> I changed the function name so as to avoid possible confusion with the
> MoveNext method.
> --

> Dirk Goldgar
> (remove NOSPAM from reply address)



> > Hi,

> > I have put a button on a custom toolbar for move next and move previous,
> but
> > the move next allows the user to go past the last record onto a new
> record -
> > which I don't want.

> > I need a function that prevents this.  Had a go, but it doesn't seem to
> > work - can anyone tell me where I'm going wrong?

> > Cheers

> > Paul

> > Function movenext()

> > Dim frm As Form, rst As Recordset

> > Set frm = Screen.ActiveForm
> > Set rst = frm.RecordsetClone

> > If Not rst.EOF Then
> > DoCmd.GoToRecord , , acNext
> > End If

> > End function



Wed, 24 Sep 2003 15:23:30 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Data control will not refresh/move to next record

2. Disconnected Recordset will not move to the next record

3. going to next record after inserting a new record

4. Moving from New Record to Existing Record in Code

5. How to move to the next record?

6. Disable move to prev/next record when turning mouse wheel

7. How to move to the next record

8. How to make combo box move to next record

9. Doing Error Checking before moving to next record

10. Move Next Record

11. How to move to the next record?

12. Move to next record in DAO

 

 
Powered by phpBB® Forum Software