我也发现在SQL_SERVER中存在类似的问题

解决方案 »

  1.   

       '建立考勤临时数据表(TempProcessedDataTable)
    SQlConditonForCreate = "" _
                    & "SELECT  " & ArrayFildsString(0) _
                    & " Into TempProcessedDataTable  FROM ProcessedData " _
                    & "WHERE  " & SqlConditionForProcessdata & " order by AttendDate asc"
        
       Debug.Print SQlConditonForCreate
       Dim dbs As Database
        MyPath = App.Path + "\database\"
       Set dbs = OpenDatabase(MyPath & "main.mdb")
       dbs.Execute SQlConditonForCreate
       dbs.Close
              
       '得到考勤库语句
        SentenceForProcessdata = "{" _
                    & "SELECT * " _
                    & "FROM TempProcessedDataTable " & " " _
                    & " } " _
                    & " AS Processdata"  '建立人事临时数据表(EmployeeTempTable)
        SentenceForEmployee = " " _
                    & "SELECT  Employee.ID,EmployeeCode, ChineseName ,Department, Designation, ShiftGroup,HolidayGroup  INTO EmployeeTempTable " _
                    & "FROM Employee,HolidayGroup,ShiftGroup where " & TempCountSQL
        'SQlConditonForCreate = " INSERT INTO EmployeeTempTable " _
                            & SentenceForEmployee
       Debug.Print SentenceForEmployee
       Dim dbs As Database
        MyPath = App.Path + "\database\"
       Set dbs = OpenDatabase(MyPath & "main.mdb")
       dbs.Execute SentenceForEmployee
       dbs.Close
              
       '得到人事库语句
        SentenceForEmployee = "{" _
                    & "SELECT * " _
                    & "FROM EmployeeTempTable " & " " _
                    & " } " _
                    & " AS employee"
      '以下是建立dataReport报表的数据源   If Connection1.State = adStateOpen Then
        Connection1.Close
      End If
       Connection1.ConnectionString = "Provider=MSDataShape;Data Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & App.Path & "\database\main.mdb;Persist Security Info=False"
       Connection1.Open
       
       If rsemployee.State = adStateOpen Then
         rsemployee.Close
       End Ifrsemployee.StayInSync = False
        rsemployee.CursorLocation = adUseClient
       rsemployee.LockType = adLockBatchOptimistic
       rsemployee.CursorType = adOpenKeyset
       Debug.Print rsemployee.State
       'rsemployee.ActiveConnection = Connection1
       Connection11 = " SHAPE " & SentenceForEmployee & "  " _
                         & "APPEND (( SHAPE " _
                         & "{SELECT * FROM `CountForAttendance`}  AS CountForAttendance " _
                         & "APPEND (" _
                         & SentenceForProcessdata & " " _
                         & " RELATE 'EmployeeID' TO 'EmployeeID') AS Processdata) AS CountForAttendance RELATE 'ID' TO 'EmployeeID') AS CountForAttendance "   '关键的是以下代码   PauseTime = 5  ' 设置暂停时间。   ’如果不执行这一段语句,rsemployee.Open 就
                                            报错:EmployeeTempTable不存在
         Start = Timer   ' 设置开始暂停的时刻。
         Do While Timer < Start + PauseTime
            DoEvents   ' 将控制让给其他程序。
         Loop
          rsemployee.Open Connection11, Connection1    ’不好意思,小弟的代码太乱,敬请提出代码的书写建议