I have this form that currently has 3 subforms on it. As the person steps through the process and commits to items on the current form the next form is displayed. My problem is I keep getting a Run-time error 3211: The database engine could not lock table "tbl_CL_MakeSchStep2 because it is already in use by another person or process. Here is my code. How do I deal with this type of problem? I turned the default warning back on and it steps through as it should but stops on the strSQL statement. I should note that the subform frm_CL_SchSort is tied to the qry_CL_MakeSchStep2 which is based on the tbl_CL_MakeSchStep2. Thank you for any help you have to offer. Fay
Private Sub cmdSaveComp1_GotFocus()
Dim strSQL As String
'Turn off Warnings
'DoCmd.SetWarnings False
'Pushes the appropriate class schedule components to tbl_CL_Sch_ClassSchComp for further processing
If frm_CL_Sch_SF_SelectComp.Form.ckRegistration = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event], [Length], [SortOrder], [AlternateTitle])" & _
"VALUES ('Registration',15, 1, 'Registration'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckWelcome = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event], [Length], [SortOrder], [AlternateTitle])" & _
"VALUES ('Welcome',5, 2, 'Welcome'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckMBreak = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event], [Length], [AlternateTitle])" & _
"VALUES ('Morning Break', 15, 'Morning Break'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckLunch = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event], [Length], [AlternateTitle])" & _
"VALUES ('Lunch', 60, 'Lunch'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckABreak = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event], [Length], [AlternateTitle])" & _
"VALUES ('Afternoon Break',15, 'Afternoon Break'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckQA = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event], [Length], [CountsAsCE], [AlternateTitle])" & _
"VALUES ('Q and A', 10, True, 'Q and A'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckQAPanel = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event], [Length], [CountsAsCE], [AlternateTitle])" & _
"VALUES ('Q and A Panel',30, True, 'Q and A Panel'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckEvaluation = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event], [Length], [CountsAsCE], [AlternateTitle])" & _
"VALUES ('Evaluation', 5, True, 'Evaluation'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckOG1 = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event])" & _
"VALUES ('Objective Group 1'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckOG2 = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event])" & _
"VALUES ('Objective Group 2'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckOG3 = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event])" & _
"VALUES ('Objective Group 3'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckOG4 = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event])" & _
"VALUES ('Objective Group 4'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckOG5 = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event])" & _
"VALUES ('Objective Group 5'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckOther = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event])" & _
"VALUES ('Other'); "
End If
If frm_CL_Sch_SF_SelectComp.Form.ckOther1 = True Then
DoCmd.RunSQL "INSERT INTO tbl_CL_MakeSchStep1 ([Event])" & _
"VALUES ('Other'); "
End If
'Runs SQL statement to update the ClassID that is in a separate control on the frm_CL__Sch_SelectComp
'pulled value is then updated into SET tbl_CL_Sch_ClassSchComp.ClassID
DoCmd.RunSQL "UPDATE tbl_CL_MakeSchStep1" & _
" SET tbl_CL_MakeSchStep1.ClassID = [Forms]![frmMain]![frm_CL_Classes].[Form]![txtClassID];"
'Create a table that is a copy of tbl_CL_MakeSchStep1 so I can tie a query to the Step2 table
strSQL = "SELECT tbl_CL_MakeSchStep1.ObjectivesID, tbl_CL_MakeSchStep1.ClassID, tbl_CL_MakeSchStep1.SortOrder, " & _
"tbl_CL_MakeSchStep1.Objective, tbl_CL_MakeSchStep1.Length, tbl_CL_MakeSchStep1.CountsAsCE, tbl_CL_MakeSchStep1.Day, " & _
"tbl_CL_MakeSchStep1.Inactivate, tbl_CL_MakeSchStep1.ScheduleID, tbl_CL_MakeSchStep1.Event, tbl_CL_MakeSchStep1.AlternateTitle, " & _
"tbl_CL_MakeSchStep1.AddEvent INTO tbl_CL_MakeSchStep2 " & _
"FROM tbl_CL_MakeSchStep1 " & _
"ORDER BY tbl_CL_MakeSchStep1.SortOrder;"
DoCmd.RunSQL strSQL
'Display apporpriate form and box
frm_CL_Sch_ClassObjListing.Visible = False
frm_CL_Sch_SF_SelectComp.Visible = False
frm_CL_SchSort.Visible = True
bxObjectives.Visible = False
bxComp.Visible = False
bxSort.Visible = True
'Restarts Access standard warnings.
'DoCmd.SetWarnings True
End Sub