0

I have a form in Access that displays employee information. One of the fields on the form is a ComboBox called ReportsTo.

I'd like to create a macro that says if this particular field is blank, an error message should pop up.

I've tried a number of differed 'If' statements, but can't get anything to work.

Private Sub Form_AfterUpdate()
If Len([Forms]![Employee Form]![ReportsTo]) = 0 Then
MsgBox "Error on this field"
End If
End Sub
ranopano
  • 509
  • 2
  • 16
  • 32
  • 1
    I would try: If (Trim([Forms]![Employee Form]![ReportsTo].value) = "") OR (IsNull ([Forms]![Employee Form]![ReportsTo].value))Then – PKatona Apr 27 '17 at 20:29
  • Better yet, see this: http://stackoverflow.com/questions/19929186/combobox-null-in-if-statement – PKatona Apr 27 '17 at 20:35
  • Ok will try in about 30 minutes or so. Should I keep using the AfterUpdate or something else? – ranopano Apr 27 '17 at 20:36
  • ok, so same issue. This macro will work if I manually run it, but I would like it to run in the background automatically. Basically, if the user goes to a record where this field is blank, the message should automatically pop-up. – ranopano Apr 27 '17 at 21:15
  • 2
    Then use the `On Current` event. – Andre Apr 27 '17 at 21:41
  • That did the trick. Thank you! – ranopano Apr 27 '17 at 22:46

0 Answers0