Macro for a previous button (1 Viewer)

Shawny

Registered User.
Local time
Today, 14:01
Joined
Apr 15, 2000
Messages
64
I am trying to put a button on a form to go to the previous record. It works fine until I cklick it when I am in the first record. Then I get the halt macro bleep boxes. I tried setting the warnings to no. No workie. I got the go to next record button to work with a condition involveing Null values. Don't have that option going in the other direction. Is there a condition I can use to detect when there are no more records?
Erin
 

DJBummy

Registered User.
Local time
Today, 14:01
Joined
Jun 22, 2001
Messages
90
Hi Shawny

To be honest the best way is to use code instead of a macro.
You can use the command button wizard to create the button if you wish. Using code is much more versatile than the macros. Here is an example.

Option Compare Database
Option Explicit
Dim Message As String
Dim DialogType As Integer
Dim Title As String
Dim Response As Integer

Private Sub cmdPrevious_Click()

On Error GoTo Err_cmdPrevious_Click

Message = "This is the First Record"
DialogType = vbOKOnly + vbExclamation
Title = "First Record Warning"
DoCmd.GoToRecord , , acPrevious

Exit_cmdPrevious_Click:
Exit Sub

Err_cmdPrevious_Click:
Response = MsgBox(Message,DialogType,Title)
Resume Exit_cmdPrevious_Click

End Sub

This event procedure would be assigned to the On Click of your command button.

hth

DJ


[This message has been edited by DJBummy (edited 08-19-2001).]

[This message has been edited by DJBummy (edited 08-19-2001).]
 

Users who are viewing this thread

Top Bottom