標題:
等待上一程式完成, 才執行下一段程式
[打印本頁]
作者:
sammyc
時間:
2011-8-6 13:26
標題:
等待上一程式完成, 才執行下一段程式
有一vba 需讀取 ms sql 資料, 及複制到另一工作頁,
但由於讀取 ms sql 資料仍未更新完成, 已複制空白資料到新一頁,
有何方式等待上一程執行完成, (更新資料)才再執行,
作者:
GBKEE
時間:
2011-8-6 15:10
回復
1#
sammyc
試試看
Selection.QueryTable.Refresh BackgroundQuery:=
False
作者:
sammyc
時間:
2011-8-8 09:40
回復
2#
GBKEE
執行到此句, 卞現錯誤
Sub l_style()
'
Dim ST_NO
ST_NO = Application.InputBox("輸入款號", "輸入款號", "", 200, 100)
ST_NO = UCase(ST_NO)
' Sheets("stylebom").Select
'Cells(2, 2) = "& st_no"
Sheets("stylebom").Range("E3") = ST_NO
Application.CutCopyMode = False
With ActiveWorkbook.Connections( _
"192.168.101.203 Garment01 TxProjMatStyCons").OLEDBConnection
.BackgroundQuery = True
.CommandText = Array( "SELECT * from table 1 where style = '" & ST_NO & "'" )
.CommandType = xlCmdSql
.Connection = Array( _
"OLEDB;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=Garment01;Data Source=192.16" _
, _
"8.101.203;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=CWST021;Use Encryption for Data=False;" _
, "Tag with column collation when possible=False")
.RefreshOnFileOpen = False
.SavePassword = False
.SourceConnectionFile = ""
.SourceDataFile = ""
.ServerCredentialsMethod = xlCredentialsMethodIntegrated
End With
With ActiveWorkbook.Connections( _
"192.168.101.203 DtradeSimpleGarment01 TxProjMatStyCons")
.Name = "192.168.101.203 DtradeSimpleGarment01 TxProjMatStyCons"
.Description = ""
End With
ActiveWorkbook.Connections( _
"192.168.101.203 DtradeSimpleGarment01 TxProjMatStyCons").Refresh
Selection.QueryTable.Refresh BackgroundQuery:=False
Call c_new
End Sub
複製代碼
作者:
GBKEE
時間:
2011-8-8 14:03
回復
3#
sammyc
試試看
ActiveWorkbook.Connections("192.168.101.203 DtradeSimpleGarment01 TxProjMatStyCons").Refresh BackgroundQuery:=
False
作者:
sammyc
時間:
2011-8-11 10:42
仍是不行, 行到此時出錯誤
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)