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

addnew to subform

Status
Not open for further replies.

LaurieHamlin

Programmer
Feb 6, 2003
217
US
I'm trying to add new records to a subform. The parent has an input box for a date. I successfully get the max date from the existing records. DtDf calculates the difference between the date entered and the max date. If the max date is < the date entered, I want it to add a new record for each date. I took out the 'with RS' to put in debug.print's and it's printing the correct numbers at all 3 spots. The recordset works fine. I can manually add records, but it won't add them for me.

DtDf = DateDiff(&quot;d&quot;, MxDt, wekend)
Do While DtDf > 0
Debug.Print DtDf prints correct #
Me.[Social Security].SetFocus
datSecondaryRS.AddNew
datSecondaryRS(&quot;Social Security&quot;) = Forms![Hours Worked]![Social Security]
datSecondaryRS(&quot;Date&quot;) = DateAdd(&quot;d&quot;, 1, MxDt)
Debug.Print MxDt prints correct date
datSecondaryRS(&quot;Code&quot;) = &quot;b&quot;
datSecondaryRS(&quot;Hours&quot;) = 7
datSecondaryRS.Update
datSecondaryRS.Bookmark = datSecondaryRS.LastModified
Me.Date.SetFocus
DtDf = DtDf - 1
Debug.Print &quot;Leave =&quot;; DtDf prints correct #
Loop

I'm probably overlooking some silly little thing, but I can't figure out what. Any help would be greatly appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top