A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Help with carry over in a form



 
 
Thread Tools Display Modes
  #1  
Old January 26th, 2010, 04:24 PM posted to microsoft.public.access.forms
Nancy via AccessMonster.com
external usenet poster
 
Posts: 27
Default Help with carry over in a form

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!

--
Message posted via http://www.accessmonster.com

  #2  
Old January 26th, 2010, 04: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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:37 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.