Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Mar 2001
    Cheltenham, Gloucestershire, England
    Thanked 0 Times in 0 Posts

    Access Sub Form - required field (2000)

    I have a form with two sub forms. the main form records (info picked up from the previous form) the delivery no, item and date of delivery.

    The first sub form requires that a serial number, special comments, etc be entered - no one seems to have any difficulty with this (the form is linked through the delivery no).

    However, people keep missing the second linked form (also linked to the delcivery number onto which a date has to be typed in order to create the start of a service record for that item (requires servicing every 12 months - the first service being 12 months from the date of receipt.. It would be nice ,if there was no previous entry in that field, it picked up the delivery date showing on the main form - however I suspect that is too complex for me to deal with!

    However I would like to make it that people cannot close down the form unless there is an entry in that field.

    Since it is a sub form unless I can get someone to click into it any required field appears to be totally ignored? How please can I get this sub form to talk to the user on exit if no date has been entered.


  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Evergreen, CO, USA
    Thanked 65 Times in 64 Posts

    Re: Access Sub Form - required field (2000)

    Doing this will almost certainly require some VBA to do things behind the scene. One solution would be to force focus to the subform control on the main form as soon as all the basic info is available. Do you have situations where there is a service record already there for a delivery? If not, you could force a new record and establish the default values based on the info on the main form. Then when the user clicked in the other subform it would save the new service record. Another alternative would be to do the new service record using DAO or ADO. And taking that to the extreme, you could use an unbound form, and do all of your error and validity checking, and then save records to the three tables using DAO or ADO. But all of these involve some VBA. If you want to have a go at it, let us know and we can give you a hand with it.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Access Sub Form - required field (2000)

    The second subform can't react to anything if it doesn't contain records. You could put code in the After Update event of the text box bound to the Delivery/Received date if you're on a new record. Substitute the appropriate names in the following:

    Private Sub txtDeliveryDate_AfterUpdate()
    ' Only react if we're on a new record
    If Not Me.NewRecord Then Exit Sub
    ' Only react if delivery date has been filled in
    If IsNull(Me.txtDeliveryDate) Then Exit Sub
    ' Only react if service date is still empty
    If Not IsNull(Me.sbfSecond!txtServiceDate) Then Exit Sub
    ' Set service date to one year after delivery date
    Me.sbfSecond!txtServiceDate = DateAdd("yyyy", 1, Me.txtDeliveryDate)
    End Sub

Posting Permissions

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