Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Mandatory Fields (2K SR1)

    I am very new at using VBA.

    I have a mandatory field in a table (tblCustomers) and an input form (frmCustomerEntry). The
    MarketingID field (Mandatory) is selected from a lookup. If the operator fails to select the
    MarketingID, I want to have a message such as

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Mandatory Fields (2K SR1)

    Try the BeforeUpdate event of the form. That will allow them to enter data and navigate around the controls but will stop them from trying to save the record if your test isn't met. You can set Cancel = True to keep them in that record and set the focus back to the control bound to MarketingID.
    Charlotte

  3. #3
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Mandatory Fields (2K SR1)

    Thanks for your reply.

    Any suggestions on the coding?

    Tom

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Mandatory Fields (2K SR1)

    Warning, this is air code and I'm assuming your control is also named MarketID (which it really shouldn't be if you apply naming conventions).

    <pre>Private Sub Form_BeforeUpdate(Cancel As Integer)
    If IsNull([MarketID]) Then
    Cancel = True
    MsgBox "You must select a MarketID value in order to save this record."
    Me!MarketID.SetFocus
    End If
    End Sub</pre>

    Charlotte

Posting Permissions

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