Details section is scrolling when insert new record

  • Thread starter Thread starter Chlaris
  • Start date Start date
C

Chlaris

Dear all,

I have header and details forms, let say frmInvoiceMain and frmInvoiceDetail
In header form , I have field User Modified and Date Modified.
In details form (frmInvoiceDetails), I have code like below :

Private Sub Form_AfterUpdate()

UpdateRecordStatus Me.Parent!InvoiceNo
End Sub

Private Sub UpdateRecordStatus(strInvoiceNo As String)
Dim strSQL As String
Dim rst As DAO.Recordset
Dim db As DAO.Database

strSQL = "SELECT UserModified, DateModified "
strSQL = strSQL & "FROM tblInvoiceMain WHERE InvoiceNo= '" & strInvoiceNo
& "'"

Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
With rst
If Not .EOF Then
.Edit
!UserModified = CurrentUser
!DateModified = Now
.Update
End If
End With
rst.Close
Set rst = Nothing
End Sub

The problem is every time the user insert record in details section, then
the form (frmInvoiceDetail) will scroll up.
How to prevent the form from scrolling ?

Many thanks before.

Chlaris.
 
Why not just update the Controls on the Parent Form?

Dim PF As Access.Form
Set PF = Me.Parent
With PF
.UserModified.Value = Access.CurrentUser()
.DateModified.Value = VBA.Now()
' .Dirty = False
End With

Set PF = Nothing

HTH

Pieter
 
Pieter,

Thanks for your code. It works perfectly. The subform is not scrolling
anymore.

Regards,
Chlaris

"Pieter Wijnen"
 
Back
Top