Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I have a form with subforms for a Contract with many projects, managers, milestones, etc. I created a "Delete" button and added code to delete the "many" records first, then delete the "one" Contract record. This works pretty well. The only trouble is it leaves "#Delete" in every field that had data in it.
    I tried refreshing the form but that didn't change anything. Requery displays the first Contract which is ok but I'd rather show the form as it appears when I use the scroll wheel to scroll to the end of the records and the form is ready for the creation of a new Contract. How would I do that? Is there a simple command to "show new" while still allowing the user to use the scroll wheel to get back to the other contract records?
    Thanks for any suggestions you might have.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If you create relationships between the main table and the related tables with enforced referential integrity and with cascade delete related records set, deleting a record from the main form will automatically delete all related records in the subforms.

    If you use RunCommand acCmdDeleteRecord to delete a record, you shouldn't see #Deleted

  3. #3
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hmm... For the most part, I have enforced referential integrity but in one case, I could not. A contract can be an amendment to a contract and so must refer back to the original contract. I have a table called RefCon that contains the contract number foreign key, and the contract key to which it refers. I've had a lot of trouble getting that to work right.
    I guess I could delete that (those) record(s) first and then try the cascade delete but I suspect it might still leave the #Delete in the fields of the RefCon subform.
    Thanks for the suggestion. I might try to find a control for the scroll wheel first and see if I can get that to scroll to the end. Does that sound possible?
    Thanks

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

    RunCommand acCmdRecordsGoToLast

    or

    RunCommand acCmdRecordsGoToNew

    to move to the last record, resp. to a new record. But I'd avoid that if possible.

  5. #5
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts
    If you'd avoid it, I will too! Thanks Hans... looks like I have some work to do.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    There's nothing against using RunCommand acCmdRecordsGoToNew (or acCmdRecordsGoToLast) in itself, but it shouldn't be necessary to use it to avoid seeing #Deleted.

Posting Permissions

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