I'm new to do loops in access, and I have some code that almost does what I'd like it to do, but it needs some tweaking. I'm not sure if what I'm envisioning is possible though (or if maybe a do loop isn't the right way to do it?).
In the event form before update, I want it to look through everything tagged TLeft. If those tagged controls are blank, I want it to change the background color. Then, once it's gone through all of those controls, ideally I want it to tell the user which controls are blank in a messagebox--but I don't think that part is possible.
Currently with the code however, it gives them the messagebox each time it finds a blank. What I can't figure out is, is there a way to do that message outside of the loop but only in the case that one of the tagged controls is blank? So, don't tell the user every time, just once they've finished the loop, if any were blank?
In the event form before update, I want it to look through everything tagged TLeft. If those tagged controls are blank, I want it to change the background color. Then, once it's gone through all of those controls, ideally I want it to tell the user which controls are blank in a messagebox--but I don't think that part is possible.
Currently with the code however, it gives them the messagebox each time it finds a blank. What I can't figure out is, is there a way to do that message outside of the loop but only in the case that one of the tagged controls is blank? So, don't tell the user every time, just once they've finished the loop, if any were blank?
Code:
For Each ctl In Me.Controls
If ctl.Tag = "TLeft" And IsNull(ctl) = True Then
ctl.BackColor = RGB(255, 194, 14)
MsgBox "you must fill in all fields"
Cancel = True
End If
Next ctl