B
Beth
I have a form, frmGrades, where I input student grades. The form has a
field listing each student by id number in a limited to list combo box.
When I type a student id in the box and that student isn't in the database,
I want to capture the id I just typed, add it to the students table, and
then open my students form (frmStudents) to the newly added student's record
so I can add their name, etc.
Right now I have code that captures the value and adds the student to the
students table, and it opens the students form, but I can't get to to go to
the new student's record. I have the form opening modal so that when the
student form is closed and you return to the main grades form, it runs a
refresh and few other steps for validating.
Below is a sample of the code up to the steps where I return from the
student form.
Can anyone tell me what I am doing wrong?
Thanks,
Beth
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not a listed student. Click yes to add
this student."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("Students", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!StudentID = NewData
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing
DoCmd.OpenForm "frmStudents", , , "StudentID = NewData", , acDialog
field listing each student by id number in a limited to list combo box.
When I type a student id in the box and that student isn't in the database,
I want to capture the id I just typed, add it to the students table, and
then open my students form (frmStudents) to the newly added student's record
so I can add their name, etc.
Right now I have code that captures the value and adds the student to the
students table, and it opens the students form, but I can't get to to go to
the new student's record. I have the form opening modal so that when the
student form is closed and you return to the main grades form, it runs a
refresh and few other steps for validating.
Below is a sample of the code up to the steps where I return from the
student form.
Can anyone tell me what I am doing wrong?
Thanks,
Beth
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not a listed student. Click yes to add
this student."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("Students", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!StudentID = NewData
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing
DoCmd.OpenForm "frmStudents", , , "StudentID = NewData", , acDialog