John Clark
John.Clark at niagaracounty.com
Mon Mar 10 09:22:01 CST 2003
How weird...I am working on the exact same problem. I noticed that a program that I am about to roll out accepts any date, in the many date fields. Some of the dates need to be later than others that are there (for instance, there is a "Sent to Sheriff" field, and a "Returned from Sheriff" field, and you cannot receive it before it is sent). I used the code: If datFromSheriff.Value < datToSheriff.Value Then MsgBox "This date cannot be previous to the Sent to Sheriff Date", vbOKOnly, "Date Error" datFromSheriff = "" datFromSheriff.SetFocus End If And I have tried it in the "On Lost Focus", "On Change" (stupid), "Before Update" (there now), and "After Update" events, but none worked. It actually worked with "Lost Focus" but the SetFocus did not...it went to the next field in the tab order. Did you get this working? John Clark >>> bchacc at san.rr.com 03/09/03 01:45PM >>> Dear List I have a couple of simple validation tests: If Not IsNumeric(Nz(txtStartingRoomNumber)) Then MsgBox "Starting Room Number Must Be Numeric.", vbExclamation txtStartingRoomNumber.SetFocus Exit Sub End If If Val(Nz(txtStartingRoomNumber)) > 9999999 Then MsgBox "Starting Room Number Must Be Less Than 7 Digits.", vbExclamation txtStartingRoomNumber.SetFocus Exit Sub End If in the AfterUpdate event of txtStartingRoomNumber. But the SetFocus does not work. The focus ends up being set on the next control in the tab sequence. I tried the tests in the Lost Focus event with the same result. I know there must be a simple way to return the focus to the control but I can't see it. (Maybe I shouldn't work on Sunday but the kids are in Sunday school and it's quiet.) :) MTIA, Rocky Smolin Beach Access Software