Actually I've just noticed something else.. for the MsgBox's you have If statements when there is no need (as there is only one possible return value), you could have them like this:
..which makes an alternative option spring to mind - you could use ElseIf, eg:VB Code:
If Len(txtName.Text) < 3 Then MsgBox "Please enter a valid Drivers Name", vbOK, "Invalid driver name" txtName.Text = "" txtName.SetFocus ErrorResult = "Yes" End If
This would be tidier, avoid any issues like salvelinus was thinking of, and would probably eliminate the need for your ErrorResult variable.VB Code:
If Len(txtName.Text) < 3 Then MsgBox "Please enter a valid Drivers Name", vbOK, "Invalid driver name" ... ErrorResult = "Yes" 'check agency name is correct format etc ElseIf Len(cmbAgencyName.Value) = 0 Then MsgBox ... ... ... ... 'if no errors go to next form Else frmAgency.Hide frmTrainingClerical.Show End If




Reply With Quote
