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

MatthewLane412

New Member
Joined
Aug 23, 2017
Messages
24
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
 

Some videos you may like

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
820
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
 

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
820
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:

MatthewLane412

New Member
Joined
Aug 23, 2017
Messages
24
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.
 

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
820
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.?
 

Watch MrExcel Video

Forum statistics

Threads
1,102,134
Messages
5,484,926
Members
407,474
Latest member
Pam Sander

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top