Manipulating continuous forms...

Z

ZRexRider

I have a sub-form that acts as a continuos form. I want to allow the
user to optionally click a button at the end of the "NEW" row that will
copy some of the previous rows contents.

How do you address the previous row of a continuous form?

Oddly enough, the following works randomly (just to tease me).

Set rs = Me.RecordsetClone
' save the previous position for this continuous form
intPrevPosition = Me.Recordset.AbsolutePosition - 1
If intPrevPosition > 0 Then
' set the current position of the Clone to the form's previous
position
rs.AbsolutePosition = intPrevPosition
' get value of previous position
dblPreviousValue = rs.Fields("mnyAmt").Value
' try to update the form's current row, specific field - works
sometimes
Forms!frmSAP8!frmSubFMZ2.Form!mnyAmt.Value = dblPreviousValue

' original attempt to update the recordset never worked - below
' Me.Recordset.Fields("mnyAmount") = dblPreviousValue
End If


Thanks
 
M

Marshall Barton

ZRexRider said:
I have a sub-form that acts as a continuos form. I want to allow the
user to optionally click a button at the end of the "NEW" row that will
copy some of the previous rows contents.

How do you address the previous row of a continuous form?

Oddly enough, the following works randomly (just to tease me).

Set rs = Me.RecordsetClone
' save the previous position for this continuous form
intPrevPosition = Me.Recordset.AbsolutePosition - 1
If intPrevPosition > 0 Then
' set the current position of the Clone to the form's previous
position
rs.AbsolutePosition = intPrevPosition
' get value of previous position
dblPreviousValue = rs.Fields("mnyAmt").Value
' try to update the form's current row, specific field - works
sometimes
Forms!frmSAP8!frmSubFMZ2.Form!mnyAmt.Value = dblPreviousValue

' original attempt to update the recordset never worked - below
' Me.Recordset.Fields("mnyAmount") = dblPreviousValue
End If


You never set the recordset clone's current record, it is
unlikely that it's the same as the form's current record.

It think this should work:

With Me.RecordsetClone
.MoveLast
Me.mnyAmount = !mnyAmt
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top