Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically fill fields in new record w/values from previous record

Status
Not open for further replies.

lhughes

Technical User
Nov 17, 2000
4
US
Please help! I've prepared a form and am using autofillnewrecord macro to automatically copy certain
fields from the last record to the new record. However, instead of just copying information from the one field that I've listed in the text box default value region, it is copying all of the fields from the last record to the new record. Any ideas how I can fix this or tell me what I'm doing wrong. I've followed microsoft's direction re: same at However, it appears the macro is not looking for or finding the text box I was told to create to look up the default value fields.

Any help would be greatly appreciated!
 
You can selectively pick fields using VBA code. But you need trigger event like create a New record button.

here is a sample
------------------------------------------
Private Sub AddNew_Click()
On Error GoTo Err_AddNew_Click

Dim Value1, Value2, Value3 As Variant
Value1 = Me![field1]
Value2 = Me![field2]
Value3 = Me![field3]

DoCmd.GoToRecord , , acNewRec

Me![field1] = Value1
Me![field2] = Value2
Me![field3] = Value3

Exit_AddNew_Click:
Exit Sub

Err_AddNew_Click:
MsgBox Err.Description
Resume Exit_AddNew_Click

End Sub


DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
Thanks Doug! Could you please tell me what I would use for the Value references?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top