打开表单后如何从vb脚本运行访问事件过程 [英] How to run access event procedure from vb script after form open
问题描述
以下vb代码在特定记录处打开数据库表单。然后,我想运行附加到表单上的按钮的事件过程。我尝试创建一个运行该过程的宏,但是在运行vb脚本时,它说找不到该过程。我什至尝试将事件过程从私有更改为公开,无济于事。我什至还尝试过仅将过程的名称而不是Macro1放进去,但还是不行。我可能会丢失什么。
The following vb code opens up a database form at a specific record. I would then like to run the event procedure that is attached to a button on the form. I have tried creating a Macro that runs the procedure, but when running the vb script, it says the procedure cannot be found. I have even tried changing the event procedure from private to public with no avail. I have also even tried just putting the name of the procedure instead of the Macro1 and still a no go. What could I possibly be missing.
以下是vb脚本:
Set accessApp = CreateObject("Access.Application")
accessApp.OpenCurrentDataBase "M:\Shared Documents\Job Cost Analysis\TRAINING JOBCOST ANALYSIS DATABASE\Job_Cost_Analysis_Tracking_Training.accdb", false
accessApp.visible = true
accessApp.UserControl = true
accessApp.DoCmd.OpenForm "frmClients", , , "Clients!client_id= 100005 ", , acWindowNormal, True
accessApp.Forms("frmClients").status_ID=3
accessApp.Run "cmdImportItemStmt_Click"
accessApp.Forms("frmClients").status_ID=34
accessApp.Save
以下是访问过程:
Private Sub cmdImportItemStmt_Click()
On Error GoTo Problems
Dim filename As String
'***** CHECK TO MAKE SURE STATUS IS IN ITEMIZED STATEMENT IMPORT ***********
If Me.status_ID.Column(1) = 3 Then
If IsNull(Me.frmItemizedStmtTotals("AMT DISPUTED").Value) = True Then
filename = (copyQueue & "CLIENT_" & CStr(Me.client_ID.Value) & "\Client_" & CStr(Me.client_ID.Value) & ".xlsx")
DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel12, "Sheet1", filename, True
DoCmd.SetWarnings (WarningsOff)
'**********APPEND ITEMIZED STATEMENT***********
DoCmd.OpenQuery "append_itemized_stmt_import"
'**********UPDATE ITEMIZED STATEMENT W/ REASON CODES***********
DoCmd.OpenQuery "Update_reason_codes_by_desc_null_revcodes"
DoCmd.OpenQuery "Update_reason_codes_by_desc"
'************** If facility is OHSU remove non-billable items per contract**********
If Me.facility_ID = 102 Then
DoCmd.OpenQuery "qryOHSU_nonbillable"
End If
'**************************************************************
Me.frmISAmtsByRevenueCodes.Requery
Me.frmItemizedStmtTotals.Requery
DoCmd.DeleteObject acTable, "Sheet1"
DoCmd.SetWarnings (WarningsOn)
Else
MsgBox "UNABLE TO IMPORT IS RECORDS BECAUSE THE ITEMIZED" & vbCrLf & _
"STATEMENT'S TOTAL BILLED CHARGES ALREADY HAS A" & vbCrLf & _
"BALANCE > THAN ZERO INDICATING A PREVIOUS IMPORT", vbOKOnly, "UNABLE TO IMPORT IS RECORDS"
End If
Else
MsgBox "INACCURATE CLAIM REVIEW STATUS" & vbCrLf & _
"FOR ITEMIZED STATEMENT IMPORT", vbOKOnly, "INACCURATE CLAIM REVIEW STATUS"
End If
RecalculateTotals
Exit Sub
Problems:
Err.Clear
Resume Next
End Sub
推荐答案
要测试的VBS脚本(基于您的脚本):
VBS script for test (based on yours):
Set accessApp = CreateObject("Access.Application")
accessApp.OpenCurrentDataBase "C:\Temp\Database1.mdb"
accessApp.UserControl = true
accessApp.Run "Test1"
并在MS Access db中测试代码。
and test code in MS Access db.
您可以运行它而不会出现问题吗?
can you run it without issue?
这篇关于打开表单后如何从vb脚本运行访问事件过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!