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

Carry data over to new record

Status
Not open for further replies.

SCGuy

Technical User
Dec 26, 2000
1
US
in one of my forms (GOALS), the goals remain pretty consistent week to week with some exceptions. I would like for the value of the last entered record to show up as a new record which will require a date to be put into the Date field before it is saved. I have not had much luck locating a way to do this. any help will be greatly appreciated.
 
I haven't tested this--I don't have access to Access @ work :)

Form_AfterUpdate ()
set rstpref = CurrentDb.OpenRecordset("temp")
do while not rstpref.eof
respref.delete
respref.movenext
loop

'put current forms data into temp table
rstpref.AddNew
rstpref.MyFieldName1 = Me.MyFieldName1
rstpref.Update

Form_Current ()
'open temp table and find its last entry
set rstpref = CurrentDb.OpenRecordset("temp")

'if temp table is not empty and the form is at
'a new record fill in the previous value
If Not .rstpref.EOF and Me.NewRecord Then
Me.MyFieldName1 = rstpref.MyFieldName1
Endif

This is just one way I have seen it done.

Hope this helps,
Mickey
 
Here is a cool way to do it that I learned from someone here at Tek Tips (but I can't remember who it was, Sorry!!).

Private Sub Fieldname_AfterUpdate()
Me.Fieldname.DefaultValue = """" & Me.Fieldname.Value & """"
End Sub

This changes the default value of the field to whatever you entered in the text box. You need the """" if it is a string value because if the default value propert is a text string, it needs quotes around it. Mike Rohde
rohdem@marshallengines.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top