Private Sub Form_Activate()
Dim strCurrentID As String
Dim strCurrentLast As String
STU_ID = Forms![FRM_Main_Login_Students]![stuIDTextBox].Value
LastName = Forms![FRM_Main_Login_Students]![lastNameTextBox].Value
'Search for inputed values in dbo_STUDENT_DIM table.
strCurrentID = Nz(DLookup("STU_ID", "dbo_STUDENT_DIM", "[STU_ID]=" & "[STU_ID]"))
strCurrentLast = Nz(DLookup("LastName", "dbo_STUDENT_DIM", "STU_LAST_NAME=" & "LastName" WHERE strCurrentID = STU_ID))
'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.Close acForm, "FRM_New_Student_Detail", acSaveNo
DoCmd.OpenForm "FRM_Main_Login_Students", acNormal
Exit Sub
End If
'If input is found, add all user data into the fields of TBL_Students
Else
FirstName = STU_FIRST_NAME
Middle = STU_MIDDLE_NAME
LastName = STU_LAST_NAME
Campus_Box = STU_CAMPUS_ADDR1
Phone = STU_CELL_PHONE
Email = STU_EMAIL
Address = STU_ADDR1
City = STU_CITY
State_Abbreviation = STU_STATE
Zip = STU_ZIP
End If
End Sub
|