There's a several problems with your approach.
If Me.txt42 = "" Then
only checks for txt42 being populated with a Zero-Length String...while 'empty' Controls in Access usually are Null...not populated with ZLSs.
Andy49's and Ajax's suggestion of using IsNull() is a better approach.
Even better is something like this
If Nz(Me.txt42, "") = "" Then
which checks for both ZLSs and Nulls!
The After_Update event on the textbox will only fire if data is entered into the Control...or deleted from the Control...and will only be Null if data is entered and then deleted. If the Control is just ignored...never entered...it will also not fire! You can only reliably check whether a Control is populated or not using the Form_BeforeUpdate event.
Originally Posted by
adeebarsad
...I've tried using the After_Update event on the textbox
This would suggest that the Form is being used for Data Entry, which begs the question...how can you later enter data in this Control, if need be (if it later becomes available) if it is no longer Visible?
Linq ;0)>
data
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007