?
Solved

What's Wrong in my code

Posted on 2009-04-03
4
Medium Priority
?
172 Views
Last Modified: 2012-05-06
What's wrong about this 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 rs As ADODB.Recordset
Dim sql As String
Set rs = New ADODB.Recordset
    sql = "select * from The_Table where Table_No='" & lpTable_No & "'"
    rs.LockType = adLockOptimistic
    rs.CursorType = adOpenKeyset
    rs.Open sql, cn
    With rs
        If .BOF = True And _
            .EOF = True Then
            .AddNew
            !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

Open in new window

0
Comment
Question by:Whing Dela Cruz
  • 3
4 Comments
 
LVL 5

Expert Comment

by:mrcoolcoder
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

by:
mrcoolcoder earned 2000 total points
ID: 24065987
or this:

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

Open in new window

0
 

Author Comment

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

0
 
LVL 5

Expert Comment

by:mrcoolcoder
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question