2016-12-01 74 views
0

我無法理解VBA功能。代碼片段和我的問題如下:理解VBA片斷的麻煩;更改代碼以僅允許來自一個輸入的多個輸入

Sub PullItem() 

Dim PurchOrder As CimObjectVariable 
--What does this next line do? The customer is using CIMPLICITY graphics 
Set PurchOrder = CimGetScriptOwner().GetVariable("PurchOrder") 

' SQL Connection String 
    Set oADOConn = CreateObject("ADODB.Connection") 
    Set oADORecords = CreateObject("ADODB.RecordSet") 

    oADOConn.ConnectionString = PointGet("SQL.INST") & PointGet("SQL.connStr") 
    oADOConn.Open 

'If the connection failed to open, we exit the script 
    If oADOConn.State <> 1 Then 
     LogStatus IT_FAILURE,"","Failed to Connect to SQL Server" 
     End 
    End If 

    --This is all done on a single screen 
    --There's a block of 30 purchase orders 
    --As it is you can select all of them or only one of them 
    --Supposedly that's what this next block of code is doing 
    --What I need this code to do is allow the customer to select 
    --between 1 and 10 purchase orders 
    --So can you explain what is happening here and how I can accomplish 
    --what I need? 
    If PurchOrder = "AllPOs" Then 
     pOrder = "%" 
    Else pOrder = ProdOrder 
    End If 

    SQLQuery = "EXEC [dbo].[GetPO] @PurchOrder = '" & pOrder & "'" 

    oADORecords.Open SQLQuery, oADOConn 

其餘的代碼只是操縱變量。這也需要一些工作,但一次一步。

+0

我對'CIMPLICITY'完全不熟悉,但看起來您需要在那裏配置用戶界面。看起來有文件[這裏](http://proscada.ru/cimplicity/)。 – Comintern

回答

0

看來腳本試圖引用調用腳本的Cimplicity對象中的PurchOrder變量(可能是屏幕上的按鈕或其他圖形對象)。

Set PurchOrder = CimGetScriptOwner().GetVariable("PurchOrder")

沒有實際看到的應用程序,我的猜測是,在屏幕上選擇採購訂單運行一個腳本,設置了一個全局的屏幕變量PurchOrder。您發佈的腳本只是獲取該變量中的值,並通過執行存儲過程從數據庫中提取數據。

相關問題