SteveL13
asked on
Next record command button not working
I have a form that is loading by [Project]. Then I have a "Next Record" command button in the footer of the form. This button works fine to go from one record to the next record. But then I also have a combo-box on the form that allows the user to "Find" a record. The afterupdate event takes them to the desired record just fine.
But here is the problem.. After the afterupdate event has taken the user to the desired record, the "Next Record" button no longer works. Instead, they are taken to a blank record.
Here is my next record VBA code:
DoCmd.GoToRecord , "", acNext
????
But here is the problem.. After the afterupdate event has taken the user to the desired record, the "Next Record" button no longer works. Instead, they are taken to a blank record.
Here is my next record VBA code:
DoCmd.GoToRecord , "", acNext
????
Me.Filter =""
Me.FilterOn = false
ASKER
Is not working. Is taking me back to the first record.
Here is my code so far:
Private Sub cmdNextRecord_Click()
On Error GoTo Err_cmdNextRecord_Click
On Error Resume Next
Me.Filter = ""
Me.FilterOn = False
DoCmd.GoToRecord , "", acNext
Me.cmdFocus.SetFocus
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
Exit_cmdNextRecord_Click:
Exit Sub
Err_cmdNextRecord_Click:
MsgBox "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description & vbCrLf & "Error Source: " & Err.Source
Resume Exit_cmdNextRecord_Click
End Sub
Here is my code so far:
Private Sub cmdNextRecord_Click()
On Error GoTo Err_cmdNextRecord_Click
On Error Resume Next
Me.Filter = ""
Me.FilterOn = False
DoCmd.GoToRecord , "", acNext
Me.cmdFocus.SetFocus
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
Exit_cmdNextRecord_Click:
Exit Sub
Err_cmdNextRecord_Click:
MsgBox "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description & vbCrLf & "Error Source: " & Err.Source
Resume Exit_cmdNextRecord_Click
End Sub
ASKER
Actually it is taking me back to the 1st record + 1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Changed to:
Dim ID As String
ID = Me!cboProject.Value
Me.FilterOn = False
Me!cboProject.SetFocus
DoCmd.FindRecord ID
DoCmd.GoToRecord , , acNext
Me.cmdFocus.SetFocus
Dim ID As String
ID = Me!cboProject.Value
Me.FilterOn = False
Me!cboProject.SetFocus
DoCmd.FindRecord ID
DoCmd.GoToRecord , , acNext
Me.cmdFocus.SetFocus
ASKER
Thank you.
You are welcome!
ASKER