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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COPY CONTENTS OF PREVIOUS RECORD IN NEW RECORD

Status
Not open for further replies.

slapupp

Technical User
Aug 30, 2001
14
0
0
US
I have a data entry form and am trying to reduce the number of keystrokes to enter new records. Since alot of the fields are repetitive from the previos record, how can I, when entering a new record, have the value of the previous record display in the field

Thank You
 
In the AfterUpdate event of the form place code to modify the default value of the fields you want to set.

MyTextBox.DefaultValue = MyTextBox

HTH Joe Miller
joe.miller@flotech.net
 
I am not clear on the code to use to get the value of the "previous" record to come up in data entry for a new record. I looked at your advise and am still unclear.

Thank you and I look forward to your response.


 
Before you leave the previous record, you change the default value to the current record (the previous record). That's why I used the AfterUpdate event. It won't work the first time you enter the screen, but everytime the user enters a record and moves to a new one, the values they just entered are copied to the default value so when they get to the new record the "previous" record is there.

HTH Joe Miller
joe.miller@flotech.net
 
I have a similar situation and It work fine to take the previous value. But for the ""new records"" display a day zero like 12/30/1899.
 
If the previous record is always the last in a recordset, you can initialise a recordset object, use MoveLast, then copy the values from the fields to the controls on your form. Have fun! :eek:)

Alex Middleton
 
I have a similar situation I need the previous date value in my new record plus a frequency (a week, month, year, 2 weeks etc). This frequency depends to the value entry in a field in the form "Property". For the first time,the value is pick up from the form Property\FirsDatePledged after this increse the value depends this value in frequency field.
-----------------------------------------------------
Option Compare Database
Option Explicit
Private Sub Form_AfterUpdate()
Me.DatePledged.DefaultValue = "#" & DatePledged.Value & "#"
End Sub

----------------------------------------------------------
Private Sub Form_BeforeInsert(Cancel As Integer)
On Error GoTo Err_Form_BeforeInsert
Dim varX As Variant
Me![PropertyID] = Forms![Properties]![PropertyID]
'Me![DatePledged] = Forms![Properties]![FirstDatePledged]
If NewRecord Then
varX = DLookup("[NumerofDays]", "Frecuency", "[FrecuencyID] = " _
& Forms!Properties!Combo31)
If varX = "dd" Then
'fortnightly
DatePledged = DateAdd("d", 14, "#" & DatePledged.Value & "#")
Else
'weekty
DatePledged = DateAdd(varX, 7, "#" & DatePledged.Value & "#")
End If
End If

Exit_Form_BeforeInsert:
Exit Sub
Err_Form_BeforeInsert:
MsgBox Err.Description
Resume Exit_Form_BeforeInsert
End Sub

--------------------------------------
Can someone help me!!!!!
Andrea
Thanks
 
Hello slapupp,

For a simple solution, how about adding a duplicate record command button? The wizard will create it for you. HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top