Results 1 to 6 of 6

Thread: MS Access required field event procedure if another field contains a certain value

  1. #1
    New Member
    Join Date
    Aug 2017
    Location
    St. Louis, MO
    Posts
    20
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default MS Access required field event procedure if another field contains a certain value

    I am working on a split form in ms access. I would like my form to not add a record if the Sending_Category = Contractors or Salaries & Benefits, and the Sending_FTE is blank. I have tried this as an on click event for the "Add Record" Macro, and on the form as a before update event. My "add record" button stops adding records when I have this code inserted, and it doesn't work with the criteria. Any ideas? Thanks

    Code:
    If Me.Sending_Category = Contractors Then
                     If IsNull (Me.Sending_FTE) Then
                         MsgBox "You mut enter a sending FTE before this record can be saved"
                      Cancel = True
                      Me.Sending_FTE.SetFocus
                   End If
    Else
        'Do Nothing
    EndIf

  2. #2
    Board Regular
    Join Date
    May 2013
    Posts
    608
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: MS Access required field event procedure if another field contains a certain value

    Set a breakpoint in the event and walk through the code with F8.
    Chances are Sending_FTE is not null.?

    Perhaps use the NZ function?
    Code:
    If NZ(Me.Sending_FTE,"") = "" Then
    HTH
    Office 2007
    Access novice. Sometimes trying to give something back

  3. #3
    New Member
    Join Date
    Aug 2017
    Location
    St. Louis, MO
    Posts
    20
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: MS Access required field event procedure if another field contains a certain value

    No luck. Thanks for the attempt.

  4. #4
    Board Regular
    Join Date
    May 2013
    Posts
    608
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: MS Access required field event procedure if another field contains a certain value

    That is not a lot to go on?
    What *exactly* did not work?, what were the values in the controls?
    For a start you should be checking for "Contractors" as it is a string?
    Last edited by welshgasman; Jun 20th, 2019 at 02:21 PM.
    Office 2007
    Access novice. Sometimes trying to give something back

  5. #5
    New Member
    Join Date
    Aug 2017
    Location
    St. Louis, MO
    Posts
    20
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: MS Access required field event procedure if another field contains a certain value

    Sorry for the delayed response. I have figured out this much. If I type in 'Contractors' into the control source box. The code works. If I use the normal control source which pulls from another table (pasted from excel) the code doesn't work. Thanks.

  6. #6
    Board Regular
    Join Date
    May 2013
    Posts
    608
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: MS Access required field event procedure if another field contains a certain value

    Still not a lot to go on.
    However if this was my problem, I would walk through the code with F8 after setting a breakpoint.
    From what you have no said, it appears that you are not really using Contractors in some way when you pull from a table.?

    If that field is a Lookup field in the table, then it is not really Contractors, but the key for Contractors from wherever you get that data.?
    Office 2007
    Access novice. Sometimes trying to give something back

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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