INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to

Carry a value forward to the next record by Terpsfan
Posted: 16 Feb 04

I have found it helpful to carry values forward to the next record on a form.  This is how I do it.  On the form's after update event you set the control's default value to the control's present value.

If you want to do this for multiple controls, you want to set the tag property of each control to CarryForward, then iterate through each control on the form.

I did not see an FAQ on this so I submitted it.  Sorry if I am duplicating another post.


'For individual controls
Private Sub Form_AfterUpdate()
    'Setup error handling
    On Error GoTo Form_AfterUpdate_Err
    
    'Carry the batch number forward
     Me.Controls("controlname").DefaultValue = """" & Me.Controls("controlname").Value & """"
       
Form_AfterUpdate_Exit:
    Exit Sub
Form_AfterUpdate_Err:
    'Alert the user that an error has occurred
    Call ErrorHandler(Err.Number, Err.Description, "frmACCT.Form_AfterUpdate")
    
    Resume Form_AfterUpdate_Exit
    
End Sub

'For multiple controls

Private Sub Form_AfterUpdate()
    'Setup error handling
    Dim ctl as control
    On Error GoTo Form_AfterUpdate_Err
    
    'Carry the batch number forward for each control
    For Each ctl in me.Controls
      If ctl.Tag = "CarryForward"
         ctl.DefaultValue = """" & ctl.Value & """"
      End If
    Next ctl   
Form_AfterUpdate_Exit:
    Set ctl = Nothing
    Exit Sub
Form_AfterUpdate_Err:
    'Alert the user that an error has occurred
    Call ErrorHandler(Err.Number, Err.Description, "frmACCT.Form_AfterUpdate")
    
    Resume Form_AfterUpdate_Exit
    
End Sub


Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close