Autofilling parts of 2nd record in a Subfrom

G

Guest

Hi

I have a data entry form (client details) which has a subform (claim
details) based on the many relationship from client details.

After I've entered the first claim and move onto enter the second for the
same client I'd like some of the text fields to be prefilled based on the
first claim.

Can someone point me in the right direction. Thanks
 
T

Todd Shillam

Use each field's OnGotFocusEvent with the following excerpt of code (edit YourFieldName in code):

If Not Me![YourFieldName] Then
Exit Sub
Else

Dim rs As Object
Set rs = Me.Recordset.Clone

If rs.EOF Or Not Me.NewRecord Then
' don't do anything if there's no records or it is not a new record
Else
With rs

.MoveLast

Me![YourFieldName] = .Fields("YourFieldName")

End With

End If

End If

Best regards,

Todd Shillam
Hi

I have a data entry form (client details) which has a subform (claim
details) based on the many relationship from client details.

After I've entered the first claim and move onto enter the second for the
same client I'd like some of the text fields to be prefilled based on the
first claim.

Can someone point me in the right direction. Thanks
 

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