Copy "New_value" of a period as "Old_value" for next period

atisz

Registered User.
Local time
Today, 06:37
Joined
Apr 5, 2005
Messages
96
Maybe this is a simple thing, but I'm such a very-very beginer in vba, that I don't now how to do it.
What's the problem?

I have a form (with an underlaying table, of course), wich contains:
Period
Old_value
New_value

Let's say for Period1 I have
Old_value: x
New_value: y

For next period (Period2), I going to have:
Old_value: y
New_value: z

and so on.

What I wanna do is, When I click the Add button, to add data for the next period (this case Period2), I don't want to enter the Old_value for Period2 manualy, I want to copy automaticaly the New_value from Period1 as Old_value for period2.

Can you help me with this?

Thanx!
 
put this code on your Add Button

Code:
Const cQuote = """"
Me!YourControl.DefaultValue = cQuote & Me!YourControl.Value & cQuote
DoCmd.GoToRecord , , acNewRec

Replace the YourControl with the actual field names in question on your form.
 
max beat me to it :D
 
But you're storing all your values twice! Which one is correct if a confict occurs?
 
Coooooooooool!

maxmangion said:
put this code on your Add Button

Code:
Const cQuote = """"
Me!YourControl.DefaultValue = cQuote & Me!YourControl.Value & cQuote
DoCmd.GoToRecord , , acNewRec

Replace the YourControl with the actual field names in question on your form.

It's working great! Thank you very-very much!

I have another issue, maybe you can help me with that too, I will post it in a few minutes. :D
Thanx again,
Attila
 
?

lagbolt said:
But you're storing all your values twice! Which one is correct if a confict occurs?

I'm storing all my values twice? In a way yes, but I have too, this is what my application require. And I store them once in the Old_value field and once in the New_value field and for different periods. After that i can make some calculations for each period: [New_value]-[Old_value].

Maybe it's not clear enough why I need this, since I hadn't offered more details, but maxmangion's solution is great, it's exactly what I need.
 

Users who are viewing this thread

Back
Top Bottom