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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|