2014-03-26 110 views
0

我正在創建一個.vbs文件,該文件應該打開訪問權限,並在內部訪問表單調用「問題詳細信息」,但傳遞參數,這意味着如果我在我的「問題」表中有10個問題爲每個文件創建一個vbs文件,單擊時應打開正確的記錄(對於表中的每個記錄將是一個ID)。到目前爲止,這是開放的訪問,它是打開表格(問題詳情),但它是空白的。我錯過了什麼?幫助,在這裏變得瘋狂...檢查下面的代碼。這裏奇怪的是,如果我再次雙擊它將刷新並打開正確的記錄,而無需打開任何窗口..我該如何解決這個問題?我不想做兩次:)訪問VBA傳遞參數vbs文件

Public Sub sendMRBmail(mrbid) 
    DoCmd.OpenForm "Issue Details", , , "[ID] = " & mrbid 
    End Sub 

    Private Sub Create_Click() 
    On Error GoTo Err_Command48_Click 
    Dim snid As Integer 
    snid = Me.ID 
    Dim filename As String 
    filename = "S:\Quality Control\vbs\QC" & snid & ".vbs" 
    Dim proc As String 
    proc = Chr(34) & "sendMRBmail" & Chr(34) 

    Dim strList As String 

    strList = "On Error Resume Next" & vbNewLine 
    strList = strList & "dim accessApp" & vbNewLine 
    strList = strList & "set accessApp = createObject(" & Chr(34) & "Access.Application" & Chr (34)")" & vbNewLine 
    strList = strList & "accessApp.OpenCurrentDataBase(" & Chr(34) & "S:\Quality Control\Quality  DB\Quality Database.accdb" & Chr(34) & ")" & vbNewLine 
    strList = strList & "accessApp.Run " & proc & "," & Chr(34) & snid & Chr(34) & vbNewLine 
    strList = strList & "set accessApp = nothing" & vbNewLine 
    Open filename For Output As #1 
    Print #1, strList 
    Close #1 

    Err_Command48_Click: 

    If Err.Number <> 0 Then 
    MsgBox "Email Error #: " & Err.Number & ", " & "Description: " & Err.Description 
    Exit Sub 
End If 
End Sub 

這裏面是什麼一個創建VBS文件

On Error Resume Next 
dim accessApp 
set accessApp = GetObject("S:\Quality Control\Quality DB\Quality Database.accdb") 
accessApp.Run"sendMRBmail","231" 
set accessApp = nothing 
+0

可能重複http://stackoverflow.com/questions/22646849/vbs-passing-parameters - 怪異行爲) – HansUp

+0

它是一個dup,但我假設它是爲了添加正確的標籤而創建的。上面的代碼看起來像是在創建VBS文件。發佈其中一個VBS文件的內容以供審閱。 – Sorceri

+0

是的,它是重複的,我在這裏移動它來添加正確的標籤,但沒有從那裏刪除。 – Shakka

回答

0

感謝社會各界提出的投入,我已經找到了答案。我說acFormEdit在我的DoCmd結束和它的工作,看看下面:

DoCmd.OpenForm "Issue Details", , , "[ID] = " & mrbid, acFormEdit 
[VBS傳遞參數怪異的行爲(指