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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add new record on subform not executing

Status
Not open for further replies.

vmon

IS-IT--Management
Feb 14, 2002
74
US
I have a mainform with a field that is the total of a column of a subform. I use the following code to update the field in the mainform in the after update event of the subform. After the update of the field on the main form I want to do an add new record in the subform. The problem is the add new record is not being executed. If I debug and step throiugh the code it does the add new record but when I run the form it skips the add new record. If I comment out the call it does the add new record.

Thanks in advance,
John
' sql statement that totals column on subform
Call calcRunTime

' Set field on record in mainform = to calculated value
strSql = "UPDATE tblProduction SET tblProduction.
[RunTime] = " & strQuote & RunTime & strQuote & " " _
& "WHERE tblProduction.[ReferenceId] = " & [Forms]![frmproduction]![ReferenceId]

CurrentDb.Execute strSql

DoCmd.GoToRecord , , acNewRec
 
When you say, after update in the subform. Is this the after update at the form level or an individual field in a record? The after update is fired when you tab out of the record, so if your form allows "add record" why are you going to a new record with the macro? The tab should take you to a new record.
 
The after update is at the form level. I want to do an add record in the subform but after a record is added focus moves to the top record in the subform. The "Call" calculates a value and sets it on the mainform record then focus moves to the top record of the subform and the add new record is not executed when I tab out of a new record. So I added a statement to do the add new record in after update of the form. It does the add new record in debug but not when I run the form. Any ideas? If I comment out the call the add new record working in run mode.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top