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

    require data entry in Date control (2000 all updat

    Form has 2 tab pages

    Page 1 has frmCustomers

    Page 2 has a subform "fsubProjects"...plus a nested subform "fsubMaterials"

    The first control in fsubProjects is QuoteDate. It is set as a required field in the table, but that seems to have to effect in the form.

    What I want to do is prevent the user from going anywhere else on fsubProjects...especially not to the fsubMaterials...without filling in this QuoteDate.

    I have tried placing code on the Exit event for QuoteDate...
    <code>If IsNull(Me.QuoteDate) then
    Cancel = True
    Me.QuoteDate.SetFocus
    End If</code>

    Trouble is this is too restrictive, as it assumes that just by virtue of being there the user wants to make a new record.

    Having a message box in this code, asking whether or not the user wishes to continue is not helpful, as every time you go to a different Customer on the main form, this message pops up.

    I have tried to place code on the fsubProjects Current event, and on the Before Insert event.

    So far, no success.

    Any suggestions?

    Thanks.

    Tom

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

    Re: require data entry in Date control (2000 all updat

    You can use code like this in the Before Insert event of fSubMaterials:

    Private Sub Form_BeforeInsert(Cancel As Integer)
    If IsNull(Me.Parent!QuoteDate) Then
    MsgBox "Please enter a quote date before entering data here!", vbExclamation
    Cancel = True
    Me.Parent.SetFocus
    Me.Parent!QuoteDate.SetFocus
    End If
    End Sub

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

    Re: require data entry in Date control (2000 all u

    Yep, that works, but I have to remove the line "Me.Parent.SetFocus"

    That line raises an Invalid Method error. But the code works fine without it.

    Thanks.

    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
  •