Private Sub yesButton_Click()
Dim strCurrentID As String
Dim strCurrentLast As String
Dim strTempID As String
Dim strTempLast As String
strTempID = Forms![FRM_Main_Login_Students]![stuIDTextBox].Value
strTempLast = Forms![FRM_Main_Login_Students]![lastNameTextBox].Value
'Search for inputed values in dbo_STUDENT_DIM table.
strCurrentID = Nz(DLookup(strTempID, "dbo_STUDENT_DIM", "[STU_ID]=" & strTempID))
strCurrentLast = Nz(DLookup(strTempLast, "dbo_STUDENT_DIM", "[STU_LAST_NAME]='" & strTempLast & "' and [STU_ID]=" & strTempID))
'If input is not found in TBL_Students, give error message and return to main login screen
If strCurrentID = -1 Or strCurrentLast = "" Then
If MsgBox("The information you entered did not match any IWU student records. Please try again.", _
vbOKOnly, "Invalid Entry") = vbOK Then
DoCmd.OpenForm "FRM_Main_Login_Students", acNormal
DoCmd.Close acForm, "FRM_First_Time_Message_Students", acSaveNo
Exit Sub
End If
'If input is found, add all user data into the fields of TBL_Students
Else
DoCmd.Close acForm, "FRM_First_Time_Message_Students", acSaveYes
DoCmd.OpenForm "FRM_New_Student_Detail", acNormal, "", , , acWindowNormal
End If
End Sub
|