Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

What's Wrong in my code

Posted on 2009-04-03
Medium Priority
171 Views
!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
Question by:Whing Dela Cruz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3

LVL 5

Expert Comment

ID: 24065983
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

LVL 5

Accepted Solution

mrcoolcoder earned 2000 total points
ID: 24065987
or this:

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

Author Comment

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

0

LVL 5

Expert Comment

ID: 24068014
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

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month7 days, 6 hours left to enroll