Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access has an error when I use Private Sub Form_Current()

Status
Not open for further replies.

grgimpy

Programmer
Nov 1, 2006
124
US
My main form has a tab control, with each tab containing a form and subform. When the main form is opened the subforms automatically scroll to the most recent record with

Private Sub Form_Load()
DoCmd.GoToRecord , , acLast
End Sub

if I try and use the code:

Private Sub Form_Current()
DoCmd.GoToRecord , , acLast
End Sub

so that each time I add a new a record, the subform automatically scrolls down and displays the recently added record, i get an error. it closes my entire database and asks me to send an error report to microsoft. why is this code not working with my subforms?
 
The current event fires 'when you move to a new record'.
You are asking it to move to the newest record every time you try to select a record in the subform - not a good idea.

Try using the 'after insert' event (after adding new record).

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top