View Single Post
  #2  
Old January 26th, 2010, 03:51 PM posted to microsoft.public.access.forms
ruralguy via AccessMonster.com
external usenet poster
 
Posts: 1,172
Default Help with carry over in a form

This is what I use: http://www.mvps.org/access/forms/frm0012.htm

Nancy wrote:
I used Allen Browne's instructions to assign values from the last record in
one of my database forms. I created this in Access 2003. I have recently
updated to 2007 and now the code won't work. I've been getting excellent help
trying to fix the error in this forum but in the mean time I tried to find
another way to carry over my data. So, I kept Allen Browne's code as Module 1
but replaced the Before Insert event procedure with the following code:

Private Sub Form_BeforeInsert(Cancel As Integer)

End Sub

Private Sub Form_Current()
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
If Me.NewRecord Then
If rs.RecordCount 0 Then
rs.MoveLast
With Me
.Supervisor.DefaultValue = rs!Supervisor
.Date.DefaultValue = rs!Date
.Day.DefaultValue = rs!Day
'all other fields
End With
Else
'sets the default to nothing
With Me
.Supervisor.DefaultValue = ""
.Date.DefaultValue = ""
.Day.DefaultValue = ""
'all other fields
End With
End If
End If
End Sub

This carries the data over just fine, but every time I change the value of
one record, it goes back and changes the value of all the records I just
entered. Also, when I open the table up that this form writes to, the three
values that I have carried over is blank. Is there any way to fix this or
should I stick with trying to work out Allen Browne's code in 2007? All I
want is for my three fields to carry over so there isn't excessive typing.
Thanks in advance for any help!


--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201001/1