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

    delete subform record (Access 2000 all updates)

    I have a form [frmVolunteerSchedule], single form. Its controls are VolunteerID, FirstName and LastName

    On it is a subform, [frmVolunteerSchedule subform], continuous form. Controls are VolunteerID, VolDate, Present.

    If the user enters a date in VolDate, the Present box is supposed to be checked, and I can set code to ensure this happens. However, there is a Default value in the VolDate control, and it is derived from the previous VolDate entered. So it is fairly easy for the user to click in that field, decide that she really doesn't want to enter Present for this Volunteer and go on to the next record in the main form...but when she does that will force the Present box to be checked.

    Therefore I would like a message to appear asking whether or not she wanted to enter a record in the subform for that Volunteer. If Yes, the Present box would be checked. If No, then delete the record. I can get the Yes part. Where I am having the problem is getting the No part. Anything I have tried has failed to either Undo or Delete the subform record.

    What would be the code for accomplishing the deletion of the subform record before going on to the next record in the main form?

    Tom

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

    Re: delete subform record (Access 2000 all updates)

    Have you tried Me.Undo?

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

    Re: delete subform record (Access 2000 all updates)

    Hans
    Yep, sure have. I am wondering if perhaps the derived Default value for the VolDate control gets in the way of the Me.Undo function.

    The default value is set on the AfterUpdate event for VolDate, and is...
    Me.VolDate.DefaultValue = """" & Me.VolDate.Value & """"

    Tom

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

    Re: delete subform record (Access 2000 all updates)

    A default value only becomes effective when the user enters something in the new record. If the user moves to a new record, the default value is displayed, but if the user then move back to the previous record without changing anything, the new record disappears without a trace. This brings me to another point: if the user doesn't change anything in a new record, it is impossible to move to the next new record. So I don't understand what is happening.

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

    Re: delete subform record (Access 2000 all updates)

    Hans
    Your points are well taken. However, here's what happens.

    The user is on John Smith's record in the main form. She goes to the subform, enters a VolDate (which becomes the default value for the VolDate control in the next subform record), but then doesn't check the Present box because she has decided that she really doesn't want an entry for John Smith at this time of entry. So she clicks the next button on the main form to go to the record for Jim Wiggins. John Smith's record in the subform is left with a VolDate but no Present, and this is what I don't want to happen. There should be no VolDate without a corresponding Present checked.

    As I indicated in the original post, I can code it so that Present is always checked if there is a VolDate entry, but I would like a message to appear which gives the user the option of (a) checking the Present box or ([img]/forums/images/smilies/cool.gif[/img] undoing the record. It's this "undo" part that I can't get to work.

    Tom

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

    Re: delete subform record (Access 2000 all updates)

    Hans
    I finally worried it to death enough that I got code to work.

    On the BeforeUpdate event for the subform I put...
    If Me.Present = False Then
    Select Case MsgBox("A Volunteer Date has been entered but Present was not checked." _
    & vbCrLf & " Do you want Present checked?" _
    , vbYesNo Or vbExclamation Or vbDefaultButton1, "Present check")

    Case vbYes
    Me.Present = True
    Case vbNo
    Me.Undo

    End Select

    Previously, I had been attempting...
    If Not IsNull(VolDate) And Present = False then ... etc.
    But, for some reason, this wouldn't work.

    Simplifying it to just test for whether Present is False seems to do the trick.

    Sorry to bother you about this. It was only after working at it for what seemed like an undue amount of time that I made the original post.

    Thanks for helping.
    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
  •