cassius
08-11-2004, 03:57 AM
I have a continuous form and on one of the fields i have the following code so that everytime a change is happened it will automatically re-sort the records in descending order:
Private Sub ToClean_AfterUpdate()
Dim rs As String
rs = Me.TotalDuplicates
DoCmd.RunCommand acCmdSaveRecord
Me.TotalDuplicates.SetFocus
DoCmd.RunCommand acCmdSortDescending
Me.TotalDuplicates.SetFocus
DoCmd.FindRecord rs
Me.TotalDuplicates.SetFocus
End Sub
This code works fine!
I also have another piece of code which when the up and down arrow keys are pressed the focus will move to the next/previous record rather than the next/previous field.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo Err_Form_KeyDownSelect
Case KeyCode
Case vbKeyDownDoCmd.GoToRecord , , acNext
KeyCode = 0
Case vbKeyUpDoCmd.GoToRecord , , acPrevious
KeyCode = 0
Case vbKeyReturnDoCmd.GoToRecord , , acNext
KeyCode = 0
Case Else
End Select
Exit SubErr_Form_KeyDown:
Select Case KeyCode
Case vbKeyDownMsgBox "There are no more records to display", vbExclamation + vbOKOnly, "Warning ..."
Case vbKeyUpMsgBox "You are already at the First Record", vbExclamation + vbOKOnly, "Warning ..."
Case vbKeyReturnMsgBox "There are no more records to display", vbExclamation + vbOKOnly, "Warning ..."
Case Else
End Select
End Sub
This code also works fine!
Now the problem i am getting is the following: when i update a record and click the down arrow key, as soon as the sort occurs instead of moving to the next available record, i am getting the message which i placed in the on error of the vbdownkey i.e.
MsgBox "There are no more records to display", vbExclamation + vbOKOnly, "Warning ..."
Therefore the two pieces of code independently they work fine but when i place them on the same form i get that message.
Any ideas pls ?
Private Sub ToClean_AfterUpdate()
Dim rs As String
rs = Me.TotalDuplicates
DoCmd.RunCommand acCmdSaveRecord
Me.TotalDuplicates.SetFocus
DoCmd.RunCommand acCmdSortDescending
Me.TotalDuplicates.SetFocus
DoCmd.FindRecord rs
Me.TotalDuplicates.SetFocus
End Sub
This code works fine!
I also have another piece of code which when the up and down arrow keys are pressed the focus will move to the next/previous record rather than the next/previous field.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo Err_Form_KeyDownSelect
Case KeyCode
Case vbKeyDownDoCmd.GoToRecord , , acNext
KeyCode = 0
Case vbKeyUpDoCmd.GoToRecord , , acPrevious
KeyCode = 0
Case vbKeyReturnDoCmd.GoToRecord , , acNext
KeyCode = 0
Case Else
End Select
Exit SubErr_Form_KeyDown:
Select Case KeyCode
Case vbKeyDownMsgBox "There are no more records to display", vbExclamation + vbOKOnly, "Warning ..."
Case vbKeyUpMsgBox "You are already at the First Record", vbExclamation + vbOKOnly, "Warning ..."
Case vbKeyReturnMsgBox "There are no more records to display", vbExclamation + vbOKOnly, "Warning ..."
Case Else
End Select
End Sub
This code also works fine!
Now the problem i am getting is the following: when i update a record and click the down arrow key, as soon as the sort occurs instead of moving to the next available record, i am getting the message which i placed in the on error of the vbdownkey i.e.
MsgBox "There are no more records to display", vbExclamation + vbOKOnly, "Warning ..."
Therefore the two pieces of code independently they work fine but when i place them on the same form i get that message.
Any ideas pls ?