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
上記のようにC#に変換する必要があるVBAコードがありますが、特定のことが行われている、または起こっている理由を理解できません
たとえば、上記のコードの下Private Sub CmdValid_Click()
にあり、このボタンのプロパティをクリックすると、前色が -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が初めてです
感謝と敬意