Carry current value of a control to new records

morlan

Registered User.
Local time
Today, 11:37
Joined
Apr 23, 2003
Messages
143
Hey folks,

I'm trying to lock values in my form so that they dont have to be retyped or reselected. Does anyone have any VB wizardry they could throw at me?
The lock check boxes are just dummies right now

frmMain.JPG
 
Mike,

Can you explain what roll the txtData box has? Could you explain the code briefly?

Option Compare Database
Option Explicit

Private Sub chkLock_AfterUpdate()

If Me.chkLock = True Then
Me.txtData = Me.txtSurname
Else
Me.txtData = vbNullString
End If

End Sub

Private Sub cmdAddRecord_Click()

DoCmd.GoToRecord , , acNewRec

If Me.chkLock = True Then
Me.txtSurname = Me.txtData
End If

End Sub

Private Sub cmdClose_Click()
DoCmd.Close acForm, Me.Name
End Sub

Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub
 

Mile!

Can you explain what roll the txtData box has? Could you explain the code briefly?

Code:
Private Sub chkLock_AfterUpdate() 

    If Me.chkLock = True Then 
        Me.txtData = Me.txtSurname 
    Else 
        Me.txtData = vbNullString 
    End If 

End Sub

This looks at the checkbox and determines if it is true (save the last detail) or false (delete the last detail)

Code:
Private Sub cmdAddRecord_Click() 

    DoCmd.GoToRecord , , acNewRec 

    If Me.chkLock = True Then 
        Me.txtSurname = Me.txtData 
    End If 

End Sub


Moves to a new record and then puts the value of the last added record into the 'locked' textbox (basically an unbound textbox that's hidden) if the user has specified that the field be locked.




txtData is just there to store the info for the relevant field - it could be done with variables too.
 
Mile-O-Phile said:


Mile!



This looks at the checkbox and determines if it is true (save the last detail) or false (delete the last detail)

Code:
Private Sub cmdAddRecord_Click() 

    DoCmd.GoToRecord , , acNewRec 

    If Me.chkLock = True Then 
        Me.txtSurname = Me.txtData 
    End If 

End Sub




Moves to a new record and then puts the value of the last added record into the 'locked' textbox (basically an unbound textbox that's hidden) if the user has specified that the field be locked.




txtData is just there to store the info for the relevant field - it could be done with variables too.

Oh aye, I figured all that out now, Cheers Mike :D
 

Users who are viewing this thread

Back
Top Bottom