Solved Carry a value into a new record (1 Viewer)

Emma35

Registered User.
Local time
Today, 04:20
Joined
Sep 18, 2012
Messages
455
Hi All,
I've got a main form called frm_Add/Edit and a subform called frmsub_CalRecords. The main form provides info about a certain instrument and the subform records every time it is calibrated. On the subform, when i move to a new record i'd like the value from the previous record to appear in one of the fields....is this easily done ?. I've looked at other cases where this question was answered but i can't get any of the suggested solutions to work for me.

Any help would be great
Thanks Em
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:20
Joined
Sep 21, 2011
Messages
14,051
I used this method in one of my DBs
Code:
Private Sub Date_ID_AfterUpdate()
    If Me.chkCopy Then
        Me![Date_ID].DefaultValue = """" & Me![Date_ID].Value & """"
    Else
        Me![Date_ID].DefaultValue = 0
    End If
End Sub

I had a checkbox which was selected if I wanted to carry over values to a new record.?
This data was all FK ID long

HTH
 

Emma35

Registered User.
Local time
Today, 04:20
Joined
Sep 18, 2012
Messages
455
Thanks gasman....i tried it without the checkbox part but the control is just blank in the new record.

Code:
Private Sub txtDispTol_AfterUpdate()

  Me![txtDispTol].DefaultValue = """" & Me![txtDispTol].Value & """"
 
End Sub
 

Minty

AWF VIP
Local time
Today, 11:20
Joined
Jul 26, 2013
Messages
10,355
Try using the . to refer to the control rather than the !

Me.txtDispTol...
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:20
Joined
Sep 21, 2011
Messages
14,051
Did you update the control?, the code only runs if you do. Debug the code and see if it executes.
 

Emma35

Registered User.
Local time
Today, 04:20
Joined
Sep 18, 2012
Messages
455
Minty....tried the dot but no difference
gasman.....I got a message saying 'Variable not yet created in this context'. I'm pretty bad with debugging code so i'm probably doing something wrong
 

Minty

AWF VIP
Local time
Today, 11:20
Joined
Jul 26, 2013
Messages
10,355
What @Gasman is saying is that if you don't change the value of the tolerance control it won't set the default value for any new records.

You might need to assign the code to a different event like the form update event?
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:20
Joined
Sep 21, 2011
Messages
14,051
Can you upload the DB?, and if so, detail how to replicate the issue?
 

Emma35

Registered User.
Local time
Today, 04:20
Joined
Sep 18, 2012
Messages
455
Ok i've tried the code in the Before and After Updates events of the subform but still nothing.
gasman.....this database is enormous and it would take me hours to strip it of the sensitive stuff
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:20
Joined
Sep 21, 2011
Messages
14,051

Emma35

Registered User.
Local time
Today, 04:20
Joined
Sep 18, 2012
Messages
455
I've had a look at those links Gasman and can't get either to work for me. I'll have a go at stripping the database but it'll be at least tomorrow before i come back with anything.........thanks again for the help.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 11:20
Joined
Jul 9, 2003
Messages
16,245
Would this be of use:-

 

Emma35

Registered User.
Local time
Today, 04:20
Joined
Sep 18, 2012
Messages
455
Hi Guys,
I've been thinking that rather than strip this database (it really is huge), i'll just move the field in question on to the main form, which will solve the problem once and for all. Thanks again for all the suggestions but i think this is probably the easiest solution.

Uncle Gizmo......thank you that site looks very good although it keeps giving me an error saying something about too many redirects ?
I'll have a good look around in the next few days hopefully

Emma x
 

Users who are viewing this thread

Top Bottom