Results 1 to 14 of 14
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete Button w/ Subform (A2K)

    Ok, again I have a form and a sub form. I have created a delete button on my form down in the footer of the main form. Now what I want this to do when clicked is delete BOTH the information in the main form and the information in the sub form. The help file is almost useless since it is so damn hard to navigate half the time. Thanks for the help in advance.

  2. #2
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    Have you established a realtionship between the two tables? If so, take a look at referential integrity and cascade deleted records.

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    ok I set that, but now it's giving me some wierd errors and will not let me delete anything. This is the error I recieve.

    You cannot add or change a record because a related record is required in tblPublishing. <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    I didn't do anything except change the relationship. I've not seen this errror before and I fill out all the data in both the main form and subfrom. Any idea's on why this is telling me this? Thanks for the help. <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>

  4. #4
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    Where is tblPublishing in the relationship? When exactly are you getting this error?

  5. #5
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    Well it is on the One side of the relationship. Although the Records side shouldn't be a many because there can only be one record for every publication when it comes to our record management process. I am getting this error after I enter information in both the main for and sub form and then I click delete. Is it possible that the AutoNumber field could be whats causing it? Meaning that the autonumbers in one table aren't the same in the second table? Being the primary key that might do something, but I don't know. Thanks for the help.

  6. #6
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    The primary key in the publisher's table should be the foreign key in the records table by which the two are related. If this is not the case then you will get this error. Although, if there is only one records record per publisher I guess it could be the primary key in the other table as well. I haven't worked that much with one-to-one relationships. At any rate, if you have records records (this is rather awkward) with no matching publisher record you will get that error message. Check your relationships and also check the link child and link master fields properties of the subform control.

  7. #7
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    this is all kind of confusing to me. <img src=/S/confused.gif border=0 alt=confused width=15 height=20> I am not the best with Access. So I don't understand why Access would recognize my relationship as a One-to-many relationship. But this is how I set up my relationship. I go to Tools => Relationships and add the tables - tblPublishing, and tblRecordMan. Now I drag the ID field from tblPublishing over to the ID field of tblRecordMan. This brings up the relationship edit window. From here I click the Enforce Referential Integrity button and then select the Delete option for I don't need the update option. Anyway, I save that and then go to my form to test. I enter in some data and all that good stuff on both forms and then hit the delete button to see if it works. This is when the error pops up. Telling me I can't add or update for some such reaosn. <img src=/S/headthrob.gif border=0 alt=headthrob width=15 height=15>

  8. #8
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    Are you trying to relate on autonumber fields in both tables? This is not a good idea as they may not synch. You should be using an autonumber field in the publisher table and a number long integer field in the recordman table. This way when you enter information into the main form then go to enter info in the subform it should place the value in the autonumber ifeld in the main form to the long integer field in the subform if you have your lik child and link master field properties set up correctly.

  9. #9
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    Here's a small sample db with 2 tables a main form a subform and a delete button.
    Attached Files Attached Files

  10. #10
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    Thanks Paul <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>. That example helped alot. I changed the Autonumber field in my RecordMan to a number field and the link worked wonders. I appreciate your patience. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  11. #11
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    Hi Paul

    Using A2k (9.0.3821) SR-1 when cecking out Testdb1.mdb I get "

    "The current user account dosen't have permission to convert or enable this database."

    Any suggestions on how I can run your db?

    Thanks, John

  12. #12
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    Yeah, it's a A97 version. I'll try to post a 2k version fo you tomorrow.

  13. #13
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    Hi Paul

    I have a97.

    Usually when I open a97 db in a2k it will asked me if I want run it or convert it.

    Just suprised it did'nt ask.

    John

  14. #14
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Button w/ Subform (A2K)

    Try this one. It was created in a vanilla nonsecure environment.
    Attached Files Attached Files

Posting Permissions

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