chuckcoleman
Registered User.
- Local time
- Today, 07:49
- Joined
- Aug 20, 2010
- Messages
- 363
Hi, I have a continuous form that produces typically a small number of records that includes for each record a [CustomerID]. When I see the results I click on the "Find" button that successfully opens the Customer Form and finds the customer that matches the [CustomerID] from the previous form. That all works. On the Customer Form, there are two command buttons that will navigate to the next record or the previous record. Using an example, if the first form has a customer with a CustomerID of 2559 when I click on the "Find" button it opens the Customer Form to the customer that has a [CustomerIDd] of 2559. The form is now filtered and is on record one of one. What I want the next record button to do is, (I think the logic here makes sense), is to capture the [CustomerID] of 2559, (it does), remove the filter and then go to the record where [CustomerID] = 2559 and then does DoCmd.GoToRecord , , acNext. That happens which gets me to the CustomerID of 2559 and then moves to the next record, say 2560. However, if I click on the next record button again to go to the next record, I get an error message of: "You can't go to the specified record."
So, what am I doing wrong?
Chuck
Code:
Private Sub NextRcd_Click()
On Error GoTo Err_NextRcd_Click
Dim CurrentCustomer As Integer
CurrentCustomer = Me.CustomerIDX
Me.Filter = ""
Me.FilterOn = True
DoCmd.GoToControl "CustomerIDX"
Me.CustomerIDX.SetFocus
DoCmd.GoToRecord , , , CurrentCustomer
DoCmd.GoToRecord , , acNext
CurrentCustomer = Me.CustomerIDX
Me.Filter = ""
Me.FilterOn = False
Err_NextRcd_Click_Exit:
Exit Sub
Err_NextRcd_Click:
MsgBox Err.Description
Resume Err_NextRcd_Click_Exit
End Sub
So, what am I doing wrong?
Chuck