• Status: Solved
• Priority: Medium
• Security: Public
• Views: 176

# What's Wrong in my code

!The_Total = IsNull(!The_Total) + Trim(lblDueAmount.Caption)
``````Public Sub save_Table(cn As ADODB.Connection, lpTable_No As String, Customer_name As String, Time_in As String, Time_Out As String, The_Total As String)
Dim sql As String
sql = "select * from The_Table where Table_No='" & lpTable_No & "'"
rs.Open sql, cn
With rs
If .BOF = True And _
.EOF = True Then
!Table_No = lpTable_No
End If
!Customer_name = Trim(grid.TextMatrix(grid.Row, 0))
!Time_in = Trim(grid.TextMatrix(grid.Row, 1))
!Time_Out = grid.TextMatrix(grid.Row, 5)
!The_Total = IsNull(!The_Total) + Trim(lblDueAmount.Caption)
.Update
.Close
End With
Set rs = Nothing
End Sub
``````
0
Whing Dela Cruz
• 3
1 Solution

Commented:
try this:

if IsNull(!The_Total) Then
!The_Total = CDbl(Trim(lblDueAmount.Caption))
Else
!The_Total = !The_Total + CDbl(Trim(lblDueAmount.Caption))
End If
0

Commented:
or this:

``````!The_Total=IIF(IsNull(!The_Total), 0, !The_Total) + CDbl(Trim(lblDueAmount.Caption))
``````
0

Author Commented:
Hi!
thank you so much, The code is working but can you tell what is IIF?

0

Commented:
IIF is a conditional statement.  If the first statement is evaluated to true, then the true output is sent, otherwise the false part is.

IIF(statement, true output, false output)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.