dbTalk Databases Forums  

Assigning a value for a new record, while moving back 5 spaces

comp.databases.ms-access comp.databases.ms-access


Discuss Assigning a value for a new record, while moving back 5 spaces in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Michael Kragh Pedersen
 
Posts: n/a

Default Assigning a value for a new record, while moving back 5 spaces - 01-06-2005 , 07:47 AM






I want to make a new record, and then assign it all the values of the
record 5 records back, for example, record 7, when being made will
have the values of record 2, and I'm making this in VBA. I have tried
with Recordset("ID")=Recordset.Move(-5)("ID"), but then it says
"Expected function or variable". Can anybody tell me what to do? I'm
trying very hard to make the program as short as possible, so I'm
really looking for a solution, that can be put together on one line
(and here I don't mean several lines being put together with : ), so
if that is at all possible, it would be a big help.

Michael K. P.

Reply With Quote
  #2  
Old   
PC Datasheet
 
Posts: n/a

Default Re: Assigning a value for a new record, while moving back 5 spaces - 01-06-2005 , 11:14 AM






Dim Rst As DAO.Recordset
Set Rst = Me.RecordsetClone
DoCmd.GotoRecord,,acNewRec
Rst.MoveLast
Rst.Move -5
With Rst
Me!Control1 = !Field1
Me!Control2 = !Field2
Me!Control3 = !Field3
etc
End With
Rst.Close
Set Rst = Nothing

Note - Controls 1, 2 and 3 are the names of the controls on your form bound
to Fields 1, 2 and 3 in your recordsource.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
resource (AT) pcdatasheet (DOT) com
www.pcdatasheet.com




"Michael Kragh Pedersen" <m_kragh_pedersen (AT) hotmail (DOT) com> wrote

Quote:
I want to make a new record, and then assign it all the values of the
record 5 records back, for example, record 7, when being made will
have the values of record 2, and I'm making this in VBA. I have tried
with Recordset("ID")=Recordset.Move(-5)("ID"), but then it says
"Expected function or variable". Can anybody tell me what to do? I'm
trying very hard to make the program as short as possible, so I'm
really looking for a solution, that can be put together on one line
(and here I don't mean several lines being put together with : ), so
if that is at all possible, it would be a big help.

Michael K. P.



Reply With Quote
  #3  
Old   
Michael Kragh Pedersen
 
Posts: n/a

Default Re: Assigning a value for a new record, while moving back 5 spaces - 01-07-2005 , 09:00 AM



Damn, I thought, I had been specific enough It's something, I'm
making for myself, in order to make putting in data a little easier,
therefore it's not something for distribution. Therefore, I have only a
form with one button, for starting the code, but not any other controls.

Michael K. P.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.