Thanks Ginger!
I was wondering if this same code will work when trying to pass
StudentID to the Interventions Form. Example: When I go to the
Students Registration Form I enter the data then am prompted to save
the data before any other event. When I click on the cmdintervention
button I am taken to the filter intervention form. However since this
is a new student there is not StudentID that passes to the Intervention
Form. I was hoping to be able to pass the StudentID to the
Intervention Form without having a record already tied to that
intervention. Meaning new student to open a new intervention. The
student enters his/her data then tries to enter a new intervention with
their studentID already attached to the intervention form. As stated
early in this thread the StudentID field is locked.
Here is the code that I have currently for the cmdintervention button
on the students form:
Private Sub cmdintervention_Click()
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
If IsNull(Me.StudentID) Then
MsgBox "Please enter a valid user name.", vbExclamation, "Error"
Me.StudentID.SetFocus
Exit Sub
ElseIf IsNull(Me.password) Then
MsgBox "Please enter a valid password.", vbExclamation, "Error"
Me.password.SetFocus
Exit Sub
End If
rs.Open "SELECT * FROM Students WHERE(StudentID = """ & Me.StudentID
& """ AND Password = """ & Me.password & """)", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rs.EOF Then
MsgBox "Please Save Your Information!", vbExclamation, "Error"
Me.StudentID.SetFocus
Exit Sub
End If
stDocName = "Intervention"
DoCmd.Close acForm, "frmStudents", acSaveNo
stLinkCriteria = "[StudentID]=" & "'" & Me![StudentID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , StudentID
End Sub
Any feedback is welecomed.