0

I am relatively new to SQL Server and MS Access and I want to know how to populate certain fields on a new record (in form view) based on the previous record entered. For example, I have three fields Project, RefID and DataType which will be consistent for multiple entries and the users do not want to manually select the value for each field every time they want to input new data. How do I set up a button that when clicked will populate those three fields to what the last input was?

1
  • Do you want to find data from table for first record of a data entry session or do you just want to carry forward data input into first record? If the latter, use code in each control's AfterUpdate event to set its DefaultValue property. This is a fairly common topic. Review stackoverflow.com/questions/24193828/… and stackoverflow.com/questions/24845816/… Commented Feb 10, 2021 at 11:18

1 Answer 1

0

Set the DefaultValue, but remember it is a string expression:

Private Sub Project_AfterUpdate()

    If Not IsNull(Me!Project.Value) Then
        Me!Project.DefaultValue = "" & Me!Project.Value ""
        ' or, if Project is text:
        ' Me!Project.DefaultValue = """" & Me!Project.Value """"
    End If

End Sub
Sign up to request clarification or add additional context in comments.

2 Comments

Hi, I have tried this approach and its currently returning #Name?
Double-check for typos or other errors. This is a verified method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.