Perform a go to new rec w/ retaining some info from prev rec 
Author Message
 Perform a go to new rec w/ retaining some info from prev rec

Client wants to be able to go to a new rec, but retain info from the
previous rec. For example, a new rec for each family mamber, but the address
would stay the same. Obviouly, having to key in the address for each family
member would be a waiste of time. Could someone show me how to code this?
Many thanks, Arthur


Sun, 17 Feb 2002 03:00:00 GMT  
 Perform a go to new rec w/ retaining some info from prev rec
Arthur- This might get you on your way.  The code assumes you have a form
with a button for copying fields, & one for pasting fields, and the only
field I am using is one called junk.

Using this scenario the user clicks a button if they want to save info they
want duplicated.  When they move to the desired record and click on the
paste button it updates that form/record field. You will need to add error
handler/code for things like when not all fields get filled in.  If a user
tries to copy an empty/null field and store that to a variable you will
probably get error 94 invalid use of null.

Option Compare Database
Option Explicit
' Declare variables that you will use to store info here
Dim txtTest As String

'code called from on click event of button named copy
Private Sub Copy_Click()
 txtTest = Me![junk]
End Sub

'code called from on click event of button named paste
Private Sub Paste_Click()
 Me![junk] = txtTest
End Sub

HTH Michael



Sun, 17 Feb 2002 03:00:00 GMT  
 Perform a go to new rec w/ retaining some info from prev rec
Call this function from the on current event of the form.  Put the word
"retain" in the tag property for any field that you would like repeated.
Most programmers would tell you to store the address in a separate table and
connect family members to the address using a FamilyID.  What happens when
their address changes, you will have to go to all family members and change
their address.
Phil
Function AutoFillNewRecord(F As Form)
Dim RS As Recordset, C As Control
Dim FillFields As String, FillAllFields As Integer

On Error Resume Next

' Exit if not on the new record.
If Not F.NewRecord Then Exit Function

' Goto the last record of the form recordset (to autofill form)
Set RS = F.RecordsetClone
RS.MoveLast

' Exit if you cannot move to the last record (no records).
If Err <> 0 Then Exit Function

F.Painting = False

' Visit each field on the form.
For Each C In F
    If C.Tag = "retain" Then
      C = RS(C.ControlSource)
    End If
Next

F.Painting = True

End Function


Quote:
> Client wants to be able to go to a new rec, but retain info from the
> previous rec. For example, a new rec for each family mamber, but the
address
> would stay the same. Obviouly, having to key in the address for each
family
> member would be a waiste of time. Could someone show me how to code this?
> Many thanks, Arthur



Sun, 17 Feb 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Subform retains data when going to new rec via coded rtn

2. New Rec with previous Rec data

3. Move to newrecord adds rec to db, but cant move to new rec

4. New Rec with previous Rec data

5. New Rec with Data Based on Previous Rec's Data

6. changes to all records in one rec set based on position in another rec set

7. A97: Go to new rec in 2nd level subform

8. Autofill in new rec fields based on prev rec?

9. Insert new rec, then pass new identity val back to Access97

10. E-mail rec info w/ link to DB record


 
Powered by phpBB® Forum Software © phpBB Group