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
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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
 
Upvote 0
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:
Upvote 0
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.
 
Upvote 0
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.?
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,876
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top