Copy previous record fields into new record form fields (1 Viewer)

Pat Hartman

Super Moderator
Staff member
Local time
Today, 10:15
Joined
Feb 19, 2002
Messages
42,983
You're getting advice on how to work around the problem of an unnormalized schema. If you want to build a better foundation, please start a new thread with that as a goal so we can be clear what we are trying to do and we are not offering contradictory solutions.
 

PuzzledNH

Registered User.
Local time
Today, 10:15
Joined
Nov 4, 2019
Messages
36
You're getting advice on how to work around the problem of an unnormalized schema. If you want to build a better foundation, please start a new thread with that as a goal so we can be clear what we are trying to do and we are not offering contradictory solutions.

Hi Pat,
I was thinking the same thing. I opened a new thread in the TABLES forum called Table Design & Relationships to pursue the disorganized tables.
This thread will remain limited to copying data to a new record.
Thank you.
 

PuzzledNH

Registered User.
Local time
Today, 10:15
Joined
Nov 4, 2019
Messages
36
No. I said to scrap the before update event entered by mistake

Code:
Option Compare Database
Option Explicit

Private Sub Product Line_AfterUpdate()
Me.[Product Line].DefaultValue = "'" & Me.[Product Line] & "'"
End Sub

Thank you for the clarification. It helps my understanding. I typed the code exactly as you provided and get an error message. "Compile error. Expected end of statement."
Attached are a couple of images showing the info entered (Capture1) and the error message (Capture2).
Any help to fix this is appreciated.
Thank you.
 

Attachments

  • Capture1.jpg
    Capture1.jpg
    94 KB · Views: 110
  • Capture2.JPG
    Capture2.JPG
    85.3 KB · Views: 113

jdraw

Super Moderator
Staff member
Local time
Today, 10:15
Joined
Jan 23, 2006
Messages
15,364
For reference - do not use field or object names with embedded spaces - to avoid syntax errors that will materialize sooner or later.
 

apr pillai

AWF VIP
Local time
Today, 19:45
Joined
Jan 20, 2005
Messages
735

isladogs

MVP / VIP
Local time
Today, 14:15
Joined
Jan 14, 2017
Messages
18,186
Sorry. As already pointed out, the issue was the embedded space in Product Line. The code should have an underscore as shown in RED below

Code:
Option Compare Database
Option Explicit

Private Sub Product[B][COLOR="Red"]_[/COLOR][/B]Line_AfterUpdate()
Me.[Product Line].DefaultValue = "'" & Me.[Product Line] & "'"
End Sub
 

isladogs

MVP / VIP
Local time
Today, 14:15
Joined
Jan 14, 2017
Messages
18,186
If you don't mind spending some time to copy paste some Code, try this link for duplicating fields from previous record: https://www.msaccesstips.com/2012/02/duplicating-fields-with-conditional.html

Hi apr
That's a neat use of the tag property. Just added to your rep points!

If its OK with you, I'd like to add a link to that webpage from a similar item on my website where I use the tag property to set the visible/hidden, enable/disabled, locked/unlocked state of a group of controls at once

EDIT
Your site would also be a useful addition to this webpage Useful links. Is that also OK with you?
 
Last edited:

apr pillai

AWF VIP
Local time
Today, 19:45
Joined
Jan 20, 2005
Messages
735
Hi apr
That's a neat use of the tag property. Just added to your rep points!

If its OK with you, I'd like to add a link to that webpage from a similar item on my website where I use the tag property to set the visible/hidden, enable/disabled, locked/unlocked state of a group of controls at once
See http://www.mendipdatasystems.co.uk/set-controls/4594398114

EDIT
Your site would also be a useful addition to this webpage Useful links. Is that also OK with you?



Ok, I will add your link to my Website.


Sent from my iPhone using Tapatalk
 

isladogs

MVP / VIP
Local time
Today, 14:15
Joined
Jan 14, 2017
Messages
18,186
Hi apr
Thanks for that as well. I'll update my website accordingly later.
 

isladogs

MVP / VIP
Local time
Today, 14:15
Joined
Jan 14, 2017
Messages
18,186
Hi apr
That's a very quick way of adding useful links! Wish I'd thought of that :cool:

Now added links to your site on the following pages:

I think that covers it!
 
Last edited:

apr pillai

AWF VIP
Local time
Today, 19:45
Joined
Jan 20, 2005
Messages
735



Hi isladogs,

Sure it does. Thanks a lot.


Sent from my iPhone using Tapatalk
 

Users who are viewing this thread

Top Bottom