|
はじめまして、よろしくおねがいいたします
請求書を作成するプログラムを作成しています
F_請求元帳→F_船便請求明細にはいり、部品価格を計算し
’閉じる’ ボタンをクリックすると、計算結果がF_請求元帳に
反映されるプログラムを作成しています
しかし’閉じる’ボタンをクリックすると、以下のエラーが発生し
うまく動作しません どこが間違っているのでしょうか?
●エラー内容
()、!演算子、かっこ()の使い方が正しくありません
●プログラム内容
Private Sub 閉じる_Click()
On Error GoTo Err_閉じる_Click
Me.Refresh
Me.Requery
Dim x As String
If IsNull(Forms!F01_船便請求明細.F02_工事明細sub!部品ID.Value) = False Then
DoCmd.RunSQL "SELECT T_工事明細.ID, T_工事明細.課税SW, Sum(T_工事明 細.金額) AS 金額の合計, " & _
"Sum(T_工事明細.予算金額) AS 予算金額の合計 INTO W_合計金額 " & _
"FROM T_工事明細 " & _
"GROUP BY T_工事明細.ID, T_工事明細.課税SW " & _
"HAVING (((T_工事明細.ID)='" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "') AND ((T_工事明細.課税SW)=1));"
DoCmd.RunSQL "SELECT T_工事明細.ID, T_工事明細.課税SW, Sum(T_工事明細.金額) AS 金額の合計, " & _
"Sum(T_工事明細.予算金額) AS 予算金額の合計 INTO W_合計金額課税無 " & _
"FROM T_工事明細 " & _
"GROUP BY T_工事明細.ID, T_工事明細.課税SW " & _
"HAVING (((T_工事明細.ID)='" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "') AND ((T_工事明細.課税SW)=2));"
DoCmd.RunSQL "SELECT T_工事明細.ID, T_工事明細.課税SW, Sum(T_工事明細.金額) AS 金額の合計, " & _
"Sum(T_工事明細.予算金額) AS 予算金額の合計 INTO W_合計金額免税 " & _
"FROM T_工事明細 " & _
"GROUP BY T_工事明細.ID, T_工事明細.課税SW " & _
"HAVING (((T_工事明細.ID)='" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "') AND ((T_工事明細.課税SW)=3));"
Dim w_kin As Variant
Dim w_ysn As Variant
Dim w_kin1 As Variant
Dim w_kin2 As Variant
Dim w_ysn1 As Variant
Dim w_ysn2 As Variant
If IsNull(DLookup("金額の合計", "W_合計金額", "ID = '" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "'")) Then
w_kin = 0
Else
w_kin = DLookup("金額の合計", "W_合計金額", "ID = '" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "'")
End If
If IsNull(DLookup("予算金額の合計", "W_合計金額", "ID = '" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "'")) Then
w_ysn = 0
Else
w_ysn = DLookup("予算金額の合計", "W_合計金額", "ID = '" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "'")
End If
Forms!F_請求元帳!合計金額.Value = w_kin * 1.05
Forms!F_請求元帳!消費税テキスト.Value = w_kin * 0.05
Forms!F_請求元帳!予算合計.Value = w_ysn
If IsNull(DLookup("金額の合計", "W_合計金額課税無", "ID = '" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "'")) Then
w_kin1 = 0
Else
w_kin1 = DLookup("金額の合計", "W_合計金額課税無", "ID = '" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "'")
End If
If IsNull(DLookup("予算金額の合計", "W_合計金額課税無", "ID = '" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "'")) Then
w_ysn1 = 0
Else
w_ysn1 = DLookup("予算金額の合計", "W_合計金額課税無", "ID = '" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "'")
End If
If IsNull(DLookup("金額の合計", "W_合計金額免税", "ID = '" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "'")) Then
w_kin2 = 0
Else
w_kin2 = DLookup("金額の合計", "W_合計金額免税", "ID = '" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "'")
End If
If IsNull(DLookup("予算金額の合計", "W_合計金額免税", "ID = '" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "'")) Then
w_ysn2 = 0
Else
w_ysn2 = DLookup("予算金額の合計", "W_合計金額免税", "ID = '" & Forms!F01_船便請求明細.F02_工事明細sub!SVID.Value & "'")
End If
Forms!F_請求元帳!合計課税無.Value = w_kin1 + w_kin2
Forms!F_請求元帳!予算課税無.Value = w_ysn1 + w_ysn2
Forms!F_請求元帳!予算総合計.Value = w_ysn * 1.05 + w_ysn1 + w_ysn2
Forms!F_請求元帳!総合計.Value = w_kin * 1.05 + w_kin1 + w_kin2
Me.Requery
DoCmd.Close
Else
x = MsgBox("データーを入力していません,フォームを閉じますか?", vbYesNo, " ")
If x = vbNo Then
Exit Sub
Else
DoCmd.Close
End If
End If
Exit_閉じる_Click:
Exit Sub
Err_閉じる_Click:
MsgBox Err.Description
Resume Exit_閉じる_Click
End Sub
非常に見づらいプログラムで申し訳ありません
|
|