Details section is scrolling when insert new record

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.
 
P

Pieter Wijnen

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
 
C

Chlaris

Pieter,

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

Regards,
Chlaris

"Pieter Wijnen"
 

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