Page Down Issue

J

Jody

I have a form that has a next button built in and I want the user to only use
this button, the problem is that the user can still hit the page down key and
move on, I have a message box that pops up when this happens but the form
still goes on to the next record. I would like to have some sort of code that
keeps the form from moving on if certain criterion is not met. I would put
this on the individual fields except the fields are check boxes and the user
needs to only have one of several fields checked to be correct. I have tried
to use the gotorecord,, acprevious but I am getting runtime errors. This is
what I have so far.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Text78 <> 0 Then
MsgBox "Please fix this issue before moving on"
DoCmd.GoToRecord , , acLast
End If
End Sub
 
K

Ken Snell \(MVP\)

Trap and cancel the PageDown action. Go to Form properties and set the Key
Preview to Yes. Then put the following code on the form's KeyDown event:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyPageDown
' Cancel the PageDown action
KeyCode = 0
MsgBox "Use the button on the form to page down."
Case Else
End Select
End Sub
 
K

Klatuu

Ken's response will do part of what you want; however, even with the check
you have, it will not stop the update. In reality, it is the code, not the
use of the Page Down key.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Text78 <> 0 Then
MsgBox "Please fix this issue before moving on"
Cancel = True
Me.Text78.SetFocus
End If
End Sub

Now what will happen is that if Text78 is not 0, they will get the message,
the record will not be updated, and the cursor will be positioned in the
offending control..
 
K

Ken Snell \(MVP\)

Thanks, Klaatu... trying to do too many things at once this afternoon, and I
missed that part of her current code.
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
Top