Solved Programmatically copy one field to another (1 Viewer)

access2010

Registered User.
Local time
Today, 14:35
Joined
Dec 26, 2009
Messages
1,019
Could we please receive your suggestion on how to copy one field with the same contents to an other field, after the cursor leaves the first field.

Thank you
Nicole
 

Attachments

  • Copy_Stock_Code_296.mdb
    276 KB · Views: 112

June7

AWF VIP
Local time
Today, 13:35
Joined
Mar 9, 2014
Messages
5,423
Use code (macro or VBA) in textbox AfterUpdate event. VBA like:

Private Sub Symbol_Stock_AfterUpdate()
Me.Symbol_Stock_Y = Me.Symbol_Stock
End Sub

Why do you want to duplicate data in same record?
 

access2010

Registered User.
Local time
Today, 14:35
Joined
Dec 26, 2009
Messages
1,019
Thank you.
The Equity code for the stock exchanges is different than the equity code that Yahoo uses.
Example; Toronto the code is ABC Yahoo wants the code as ABC-TO
So the code will be copied and than adjusted
Nicole
 

June7

AWF VIP
Local time
Today, 13:35
Joined
Mar 9, 2014
Messages
5,423
Can do adjustment in copy action. Just concatenate whatever text you want.

Me.Symbol_Stock_Y = Me.Symbol_Stock & "-something"

or

Me.Symbol_Stock_Y = Me.Symbol_Stock & "-" & Me.fieldname
 

June7

AWF VIP
Local time
Today, 13:35
Joined
Mar 9, 2014
Messages
5,423
This value can be calculated in query when needed. Don't really see a need to actually save into table.
 

access2010

Registered User.
Local time
Today, 14:35
Joined
Dec 26, 2009
Messages
1,019
This value can be calculated in query when needed. Don't really see a need to actually save into table.
Thank you for your suggestion and we tried to continue the copy of the stock symbol to a third field without success.
===
Private Sub Symbol_Stock_AfterUpdate()
' copy FROM = Symbol_Stock = to = Symbol_Stock_Y
Me.Symbol_Stock_Y = Me.Symbol_Stock
' copy FROM = Symbol_Stock = to = Symbol_A
Me.Symbol_Stock_Y = Me.Symbol_Stock
End Sub
===
Could you please let us know what I have done wrong?
Thank you,
Nicole
 

June7

AWF VIP
Local time
Today, 13:35
Joined
Mar 9, 2014
Messages
5,423
What does "without success" mean - error message, wrong result, nothing happens? Perhaps need to change last line to reference Symbol_A instead of Symbol_Stock_Y.

Again, why save to table instead of calculating in query when needed?
 

access2010

Registered User.
Local time
Today, 14:35
Joined
Dec 26, 2009
Messages
1,019
This works, thank you

Private Sub Symbol_Stock_AfterUpdate()
' copy = TO = Symbol_Stock_Y = FROM = Me.Symbol_Stock
Me.Symbol_Stock_Y = Me.Symbol_Stock
' copy = TO = Symbol_A = FROM = Me.Symbol_Stock
Me.Symbol_A = Me.Symbol_Stock
End Sub
 

Users who are viewing this thread

Top Bottom