Private Sub CmdValid_Click()
On Error GoTo ErrValid:
Dim LngExec As Long
Dim varCie
Dim ret As VbMsgBoxResult
Dim StrSql
Dim DblBalance
If Me.SF.Form.Dirty Then
Me.SF.Form.Refresh
End If
DblBalance = aaRound(aaRound(Me.SF.Form.TxtCreditTotal.Value, 2) - aaRound(Me.SF.Form.TxtDebitTotal.Value, 2), 2)
If DblBalance <> 0 Then
MsgBox "Credit must be equal to credit. Press Delete if you want to delete this journal entry, or enter the appropriate values", vbCritical, "Validation refused"
Else
'---- We have to create the two record into the General ledger detail
StrSql = "EXEC SpValidGenLedDet " & str(Me.GLHCode)
LngExec = aaExecuteSP(StrSql)
If LngExec = 0 Then
DoCmd.SetWarnings (False)
StrSql = "EXEC SpDelGenLedDetTmp " & str(Me.GLHCode)
LngExec = aaExecuteSP(StrSql)
DoCmd.SetWarnings (True)
ret = MsgBox("This entry is successfully validated. Do you want to create another entry ?" & Chr(13) & Chr(10) & "click YES to add a new one , NO to close this form", vbInformation + vbYesNo, "validation accepted")
If ret = vbYes Then
varCie = Me.CboGlHInternalCie
DoCmd.GoToRecord , , acNewRec
If Not IsNull(varCie) Then
Me.GlHInternalCie = CLng(varCie)
End If
Else
DoCmd.Close acForm, Me.Name
End If
Else
MsgBox "There was an error while Writing the accounting lines into the General ledger, retry to validate or press delete to cancel the transaction"
End If
End If
finValid:
Exit Sub
ErrValid:
MsgBox "Error during validation", vbCritical, "Error"
Resume finValid
End Sub
我有一個VBA代碼,我需要轉換爲C#上面爲什麼某些事情正在做或發生VBA混淆爲什麼這個值在存儲過程執行時返回?
例如上面的代碼是在Private Sub CmdValid_Click()
並在但是我不能夠得到儘可能給予此按鈕的屬性單擊forecolor設置爲值-2147483630。當我執行代碼並檢查斷點時,我在LngExec中獲得值-2147483630。
但是程序SpDelGenLedDetTmp僅僅是一個簡單的刪除過程where子句
**
/****** Object: StoredProcedure [dbo].[SpDelGenLedTmp] Script Date: 10/28/2012 12:27:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[SpDelGenLedTmp]
(@GHDHeader_1 [int])
AS DELETE [ABOUSQL].[dbo].[TblGenLedDetTmp]
WHERE
([GHDHeader] = @GHDHeader_1)
**
Function aaExecuteSP(StrSql) As Long
On Error GoTo ErrGetData
Dim cnn As ADODB.Connection
Dim isok
Set cnn = aaDbConnect()
cnn.Execute (StrSql)
aaExecuteSP = 0
FinGetData:
Exit Function
ErrGetData:
If Err.Number <> 0 Then
aaExecuteSP = Err.Number
End If
Resume FinGetData
End Function
任何幫助,將不勝感激我是很新的VBA
感謝和問候
既然你從來沒有表現出什麼'aaExecuteSP'的樣子,這是不可能知道爲什麼這麼巧其返回值是什麼。 – Tomalak
我已添加代碼 – vini
閱讀[KB185125:如何使用VBA/C++/Java調用帶有ADO查詢的存儲過程](http://support.microsoft.com/kb/185125/en-us)。主要是代碼示例中的「Open recordset.'部分。 – Tomalak