I have a main form and a sub form.
On the main form I have some text boxes and two buttons to add records to a table table1.
The sub form is a continuous from that shows the content of table1, onLoad the sub form show the last 10 records, and the rest of the records can be seen by scrolling up.
What I am trying to do is whenever a new record is added the sub form must be updated and after that show the last 10 records again.
Here how I am doing this but does not work
Both functions work individually, but when the Update_form is called and then the DoCmd.GoToRecord is called, the DoCmd.GoToRecord part does not work, i.e. the form shows the first record instead of the specified ID.
I appreciate any help.
On the main form I have some text boxes and two buttons to add records to a table table1.
The sub form is a continuous from that shows the content of table1, onLoad the sub form show the last 10 records, and the rest of the records can be seen by scrolling up.
What I am trying to do is whenever a new record is added the sub form must be updated and after that show the last 10 records again.
Here how I am doing this but does not work
Code:
Public Sub Update_From()
Me.Form.Requery
End Sub
Public Sub Update_Goto()
Update_From
Dim ID As Long
ID = (DMax("ID", "details"))
If ID < 10 Then
ID = 1
Else
ID = ID - 10
End If
DoCmd.GoToRecord , , acGoTo, ID
End Sub
Both functions work individually, but when the Update_form is called and then the DoCmd.GoToRecord is called, the DoCmd.GoToRecord part does not work, i.e. the form shows the first record instead of the specified ID.
I appreciate any help.