Newbee question #6:
I'm looking to see if there is a better command I could be using to copy a table out of access into a MicroSoft SQL server besides Insert?
If insert is the way I have to go could I get a hand with my syntex on ending a line with the "& _"? I'm getting errors with it.
Thanks
I'm looking to see if there is a better command I could be using to copy a table out of access into a MicroSoft SQL server besides Insert?
Code:
Private Sub CopyRecordsToSQL_Click() Dim Flag As Boolean Set MyDb = DBEngine.Workspaces(0).Databases(0) Set dataarea = MyDb.OpenRecordset("dbo_DATA_AREA", DB_OPEN_DYNASET) Set SummaryData = MyDb.OpenRecordset("SupperSummary", DB_OPEN_TABLE) Dim SQLStg As String DoCmd.Hourglass True While dataarea.Flag = False Wend '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,'False')" DoCmd.RunSQL SQLStg SQLStg = "Delete * from dbo_SupperSummary" While Not SummaryData.EOF DoCmd.RunSQL SQLStg SQLStg = "Insert into dbo_SupperSummary (Crew, Asset, Quality, Operator_ID, StartTimeStamp1, & _" EndTimeStamp1, Total_time, Hour_Count, StartProduction, EndProduction, TotalProduction, DT_Cat, & _ Dt_Code, Production_Type, Shift, Status, Downtime, Expr1, Expr2, Earned_HR_Goal, Standard_Crew, & _ Department, WorkGroup, WorkCenter, EarnedPC, EarnedPCDesc, Location, Eff, Asset_Name) & _ VALUES (SummaryData.Crew, SummaryData.Asset, SummaryData.Quality, SummaryData.Operator_ID, & _ SummaryData.StartTimeStamp1, SummaryData.EndTimeStamp1, SummaryData.Total_time, & _ SummaryData.Hour_Count, SummaryData.StartProduction, SummaryData.EndProduction, & _ SummaryData.Total_Production, SummaryData.DT_Cat , SummaryData.Dt_Code, & _ SummaryData.Production_Type, SummaryData.Shift, SummaryData.Status, SummaryData.Downtime, & _ SummaryData.Expr1, SummaryData.Expr2, SummaryData.Earned_HR_Goal, SummaryData.Standard_Crew, & _ SummaryData.Department, SummaryData.WorkGroup, SummaryData.WorkCenter, SummaryData.EarnedPC,& _ SummaryDataEarnedPCDesc, SummaryData.Location, SummaryData.Eff, SummaryData.Asset_Name)" DoCmd.RunSQL SQLStg Wend SQLStg = "Delete * from dbo_DATA_AREA" DoCmd.RunSQL SQLStg SQLStg = "Insert into dbo_DATA_AREA (Id, Inuse) VALUES (1,'True')" DoCmd.RunSQL SQLStg DoCmd.SetWarnings True DoCmd.Hourglass False End Sub
Thanks
Comment