Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Remove part of record (2000 latest)

    In the data entry form frmTrinity, based on tblTrinity, there are certain circumstances where I want to take an existing entry, remove one person from the record and create a new record for the person being removed.

    An example

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Remove part of record (2000 latest)

    There is a potential danger in your method: if creating a new record fails for some reason, the data have already been deleted from the original record. You could do the following instead:

    - store the values in temporary variables.
    - create a new record and fill it from the variables.
    - go back to the original record and clear the fields that have been transferred.

    You can use the Bookmark property of the form to go back, or the UniqueID. Another method would be to add error handling. If creating a new record causes an error, go back to the original record and restore the fields that have been cleared.

  3. #3
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Remove part of record (2000 latest)

    Hans
    Thanks for your reply. The possibility of it breaking down was why I made the post.

    I had tried various ways of getting back to the record, but hadn't been successful. I'm still foggy as to how to move around in Recordsets.

    I will have to play around with the Bookmark approach and see if I can work it out.

    Tom

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Remove part of record (2000 latest)

    Try something like

    Dim strTemp As String
    Dim strTemp2 As String
    Dim varBookmark As Variant

    ' Fields to variables
    strTemp = Me.FirstName2
    strTemp2 = IIf(IsNull(Me.LastName2), Me.LastName, Me.LastName2)

    ' Current position
    varBookmark = Me.Bookmark

    ' To new record
    DoCmd.GoToRecord , , acNewRec

    ' Variables to fields
    Me.LastName = strTemp2
    Me.FirstName = strTemp

    ' Back to original position
    Me.Bookmark = varBookmark

    ' Clear fields
    Me.FirstName2 = Null
    Me.LastName2 = Null

  5. #5
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Remove part of record (2000 latest)

    Hans
    Thanks so much. That did it!

    Tom

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •