A
Ann
I have a form with two fields, one is registration no,
the other is association name.
If an invalid regNo is entered, I check it in the
underlying table, if there is no record, a message box
shown telling need to reenter a valid regno.
My code set the focus back to the regno, but after I
click message box OK, then the focus goes to the next
text fields, association name instead of regno field.
Here is the code:
SQLWhere$ = "([AssocRegistrationNo] like Forms!
[frmPrincipalCheckIn]![PrincipalNo])"
If IsNull(DLookup("[AssocName]", "tblAssociation",
SQLWhere$)) Then
MsgBox "Record not found, please enter a valid
regno"
Forms![frmPrincipalCheckIn]![PrincipalNo] = ""
Forms![frmPrincipalCheckIn]![PrincipalNo].SetFocus
Else
Me.txtPrincName =
DLookup"[AssocName]", "tblAssociation", SQLWhere$)
confirm.SetFocus
End If
the other is association name.
If an invalid regNo is entered, I check it in the
underlying table, if there is no record, a message box
shown telling need to reenter a valid regno.
My code set the focus back to the regno, but after I
click message box OK, then the focus goes to the next
text fields, association name instead of regno field.
Here is the code:
SQLWhere$ = "([AssocRegistrationNo] like Forms!
[frmPrincipalCheckIn]![PrincipalNo])"
If IsNull(DLookup("[AssocName]", "tblAssociation",
SQLWhere$)) Then
MsgBox "Record not found, please enter a valid
regno"
Forms![frmPrincipalCheckIn]![PrincipalNo] = ""
Forms![frmPrincipalCheckIn]![PrincipalNo].SetFocus
Else
Me.txtPrincName =
DLookup"[AssocName]", "tblAssociation", SQLWhere$)
confirm.SetFocus
End If