if then for access

G

Guest

i want to use this statment
If Kredit is null then Saldo = Debit
If Debit is null then Saldo = Kredit
Else
Debit-saldo
End if

any one can help ? thank`s
here, where i want to put it

Private Sub Command4_Click()
Dim mySQL As String

mySQL = "UPDATE Transactions SET Transactions.Periode =
DateSerial(Year([TransactionDate]),Month([TransactionDate]),1)"
DoCmd.RunSQL mySQL
mySQL = "DELETE FROM Dummy"
DoCmd.RunSQL mySQL
mySQL = "INSERT INTO Dummy(Kredit,Debit)"
mySQL = mySQL & " SELECT SUM(WithdrawalAmount) as Kredit,sum(DepositAmount)
as Debit"
mySQL = mySQL & " FROM Transactions"
mySQL = mySQL & " WHERE Periode <=DateAdd('m',-1,#" &
[Forms]![Filter1]![Periode]
mySQL = mySQL & "#)"
DoCmd.RunSQL mySQL
mySQL = "INSERT INTO Dummy(Periode,AccountID,Kredit,Debit)"
mySQL = mySQL & " SELECT Periode,AccountID,SUM(WithdrawalAmount) as
Kredit,sum(DepositAmount) as Debit"
mySQL = mySQL & " FROM Transactions"
mySQL = mySQL & " WHERE Periode =#" & [Forms]![Filter1]![Periode]
mySQL = mySQL & "# GROUP BY Periode,AccountID"
DoCmd.RunSQL mySQL
mySQL = "INSERT INTO Dummy2(Periode,AccountID,Kredit,Debit,saldo)"
mySQL = mySQL & " SELECT
Periode,AccountID,Kredit,Debit,sum([Debit-kredit])as saldo
mySQL = mySQL & " FROM Dummy"
mySQL = mySQL & " WHERE Periode =#" & [Forms]![Filter1]![Periode]
mySQL = mySQL & "# GROUP BY Periode,AccountID"
DoCmd.RunSQL mySQL
DoCmd.OpenQuery "Query2"

End Sub
 
G

Guest

Hi, is this what you mean ?

If IsNull(Kredit)=True And IsNull(Debit)=False then
Saldo = Debit
Elseif IsNull(Kredit)=False And IsNull(Debit)=True then
Saldo = Kredit
Else
Debit = saldo 'You may want to assign the value Debit-Saldo to
a variable
End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top