Auto populate field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would I code, say, Field2, such that on entry

If Field1 is not null Then
Field2 = previous record's Field2.Value
Else Exit Sub

I don't know how to refer to a previous record's field's value...
 
How would I code, say, Field2, such that on entry

If Field1 is not null Then
Field2 = previous record's Field2.Value
Else Exit Sub

I don't know how to refer to a previous record's field's value...

There are two easy ways to do this. If you're entering data in a table
or query datasheet (which is not desirable!) or in a Form, you can
type Ctrl-' to copy the most recently entered value in the field.

To automate this in a Form (you can't do this in a table or query),
set the control's DefaultValue property in the control's AfterUpdate
event:

Private Sub controlname_AfterUpdate()
Me.controlname.DefaultValue = Chr(34) & Me.controlname & Chr(34)
End Sub

Chr(34) is the " character, and the DefaultValue property must be a
string value regardless of the field's datatype.

John W. Vinson[MVP]
 

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

Back
Top