Error is happening on line 30 below when trying to delete an SQL server table. The thing I cannot get my mind around, is I am deleting a table in the same SQL Server on line 24 without any errors? And I'm trying to handle it the same way.
In the Microsoft Visual Basic error box:
Run-time Error '3086;:
Could not delete from specified tables.
I put it in the title of the question. But now I realize it isn't that apparent it is the error description. If you are looking for something else let me know.
Code:
Private Sub CopyRecordsToSQL_Click() Dim Inuse As Boolean Dim Twait As Date Set MyDb = DBEngine.Workspaces(0).Databases(0) Set dataarea = MyDb.OpenRecordset("dbo_DATA_AREA", DB_OPEN_DYNASET) Set SQLSummaryData = MyDb.OpenRecordset("dbo_SupperSummary", DB_OPEN_DYNASET) Set SummaryData = MyDb.OpenRecordset("SupperSummary", DB_OPEN_TABLE) Dim SQLStg As String 'Check Data Area Flag DoCmd.Hourglass True If dataarea.Inuse = 0 Then Twait = Time Twait = DateAdd("s", 15, Twait) Do Until TNow >= Twait TNow = Time Loop End If 'Set Data Area Flag DoCmd.SetWarnings False SQLStg = "Delete * from dbo_DATA_AREA" DoCmd.RunSQL SQLStg SQLStg = "Insert into dbo_DATA_AREA (Id, Inuse) VALUES (1,0)" DoCmd.RunSQL SQLStg 'Copy Data SQLStg = "Delete * from dbo_SupperSummary" DoCmd.RunSQL SQLStg SQLStg = "Insert into dbo_SupperSummary (Crew, Asset, Quality, Operator_ID, StartTimeStamp1 VALUES (SummaryData.Crew, SummaryData.Asset, SummaryData.Quality, SummaryData.Operator_ID, SummaryData.StartTimeStamp1)" DoCmd.RunSQL SQLStg
Run-time Error '3086;:
Could not delete from specified tables.
I put it in the title of the question. But now I realize it isn't that apparent it is the error description. If you are looking for something else let me know.
Comment