Hi
Thansk to everybodies help over the last few days I have learnt a great deal. After a rethionk I now have reduced a 3 step process to 2. The insertion of a record and the update of that record
Dim dbsCollege As DAO.Database
Dim rstStudentAnnualcourses As DAO.Recordset
Dim intStuID As Integer
Dim strSQL As String
Dim intCrsID As Integer
Dim intLastRecord As Integer
intStuID = Forms!frmStudentCourses!StudID
Set dbsCollege = CurrentDb
Set rstStudentAnnualcourses = dbsCollege.OpenRecordset("tblStudentsAnnualCourses")
strSQL = "INSERT INTO tblStudentsAnnualCourses([StuAnnCrsesStuID]) VALUES (" & intStuID & ")"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
intStuID = 0
'Msg = "Record added Waiting for Course Selection"
Me!LabelSelectaCourse.Visible = True
Me!cboSelectCourse = ""
Me!cboSelectCourse.Visible = True
rstStudentAnnualcourses.MoveLast
intLastRecord = rstStudentAnnualcourses!StuAnnCrsesID
intCrseID = 5
strSQL = ""
strSQL = strSQL & " Update tblStudentsAnnualcourses "
strSQL = strSQL & " Set StuAnnCrsesCrseID = " & intCrseID
strSQL = strSQL & " WHERE StuAnnCrsesID = " & intLastRecord
DoCmd.RunSQL strSQL
intCrseID = 0
'Msg = "Course Added"
'DoCmd.Requery Forms!frmStudentCourses.subfrmCoursesStudent!StuAnnCrsesID
DoCmd.SetWarnings True
is the latest draft. If I explicitly declare intCrseID it works fine but I would like to take it from the cboSelectCourse. How?
Then next steps are the msg boxes and the requery to display the new record in the subform. Msg boxes preferably timed so that they are visual confirmations. How?
All contributions gratefully accepted.
Paul
Thansk to everybodies help over the last few days I have learnt a great deal. After a rethionk I now have reduced a 3 step process to 2. The insertion of a record and the update of that record
Dim dbsCollege As DAO.Database
Dim rstStudentAnnualcourses As DAO.Recordset
Dim intStuID As Integer
Dim strSQL As String
Dim intCrsID As Integer
Dim intLastRecord As Integer
intStuID = Forms!frmStudentCourses!StudID
Set dbsCollege = CurrentDb
Set rstStudentAnnualcourses = dbsCollege.OpenRecordset("tblStudentsAnnualCourses")
strSQL = "INSERT INTO tblStudentsAnnualCourses([StuAnnCrsesStuID]) VALUES (" & intStuID & ")"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
intStuID = 0
'Msg = "Record added Waiting for Course Selection"
Me!LabelSelectaCourse.Visible = True
Me!cboSelectCourse = ""
Me!cboSelectCourse.Visible = True
rstStudentAnnualcourses.MoveLast
intLastRecord = rstStudentAnnualcourses!StuAnnCrsesID
intCrseID = 5
strSQL = ""
strSQL = strSQL & " Update tblStudentsAnnualcourses "
strSQL = strSQL & " Set StuAnnCrsesCrseID = " & intCrseID
strSQL = strSQL & " WHERE StuAnnCrsesID = " & intLastRecord
DoCmd.RunSQL strSQL
intCrseID = 0
'Msg = "Course Added"
'DoCmd.Requery Forms!frmStudentCourses.subfrmCoursesStudent!StuAnnCrsesID
DoCmd.SetWarnings True
is the latest draft. If I explicitly declare intCrseID it works fine but I would like to take it from the cboSelectCourse. How?
Then next steps are the msg boxes and the requery to display the new record in the subform. Msg boxes preferably timed so that they are visual confirmations. How?
All contributions gratefully accepted.
Paul
