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

MatthewLane412

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

welshgasman

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

Forum statistics

Threads
1,078,443
Messages
5,340,312
Members
399,367
Latest member
ahmed elsaid

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top