If Not ValidDates() Then
MsgBox "Some of the dates entered are invalid" Screen.MousePointer = vbDefault Exit Sub End If 'Notice that since this block leaves the sub early via the Exit Sub statement 'you must reset the mouse pointer to its default shape. 'Next, enter the following ValidDate function, which uses VB's built-in 'Controls array: '_________________________________________________________ Private Function ValidDates() As Boolean Dim ctl As Control Dim bInValid As Boolean For Each ctl In Me.Controls Debug.Print ctl.Name If TypeOf ctl Is TextBox Then If InStr(1, ctl.Name, "Date") > 1 And _ ctl.Text "" Then bInValid = Not IsDate(ctl.Text) If bInValid Then ValidDates = False Exit Function End If End If End If Next ValidDates = True End Function 'Run the project and enter the values 2/7/64, 7/8/93, and To be scheduled 'in the three fields. When you click Update, a message box will inform you 'that a date is invalid. Click OK, then enter 10/31/96 in the Date Of Last 'Review text box-this time, VB won't object when you click Update |