Priya
Priya

Reputation: 95

how to determine a different entry in a field in lotus notes

I have an Add button in the dialog form to add items, its quantity, price , currency and list in the field below. There is a currency field in the form. it is a drop down list with many currencies. The currency should be same on adding the items. if there is currency change, message box should appear. below is the part of the code for add button event. "cur" is the currency field.

Sub Click(Source As Button)
    'On Error Goto errhandle
    Dim work As New notesuiworkspace  
    Dim uidoc As notesuidocument
    Dim doc As notesdocument
    Dim item As String, weight As String
    Dim qty As String, price As String 
    Dim sbtotal As String   
    Dim gtotal As String

    Set uidoc = work.currentdocument 
    Set doc =uidoc.Document

    item = uidoc.FieldGetText("Item")
    qty = uidoc.FieldGetText("Qty")
    price = uidoc.FieldGetText("Price")
    cur = uidoc.FieldGetText("cur")
    sbtotal= uidoc.FieldGetText("SubTotal")

    Call uidoc.Refresh

    'weight = uidoc.FieldGetText("W_Qty")
    'adj = uidoc.fieldGetText("Adj")
    remark = uidoc.FieldGetText("Remarks")
    If item = "" Or qty = "" Or price = "" Then 
        Msgbox "Please complete the data entry ", 16, "Error - Incomplete Data Entry"
        Exit Sub
    End If
        recordNo = uidoc.fieldgettext("ww")

    If recordNo = "" Then
        recordNumber = 0 
    Else 
        pos = Instr(recordNo,";")
        If  pos > 0 Then 
            number = Right(recordNo , pos -1) 
        Else
            number = Left(recordNo , pos +1)
        End If 
        recordNumber = Cint(number)
    End If      


    recordNumber = recordNumber + 1  
    'to append text
    Call uidoc.FieldAppendText("no" ,";" & Cstr(recordNumber))     
    Call uidoc.FieldAppendText("Item1" ,";" & item)
    Call uidoc.FieldAppendText("Q1" , ";" & Cstr(qty))
    Call uidoc.FieldAppendText("amt" , ";" & Cdbl(price))
    Call uidoc.FieldAppendText("C1" , ";" & Cstr(cur))
    Call uidoc.FieldAppendText("TSubTotal" , ";" & Cdbl(sbtotal)) 


     'clear entering data
    uidoc.FieldClear("Remarks")
    uidoc.FieldClear("Item")
    uidoc.FieldClear("Qty")     
    uidoc.FieldClear("Price")
    'uidoc.FieldClear("W_Qty")          
    Call uidoc.FieldSetText("SubTotal","0.00")
    uidoc.refresh




    Dim subtotal As Double
    subtotal = 0
    Forall stotal In doc.TSubTotal
        If stotal <> "" Then
            subtotal = subtotal + Cdbl(stotal)
        End If
    End Forall
    total =  subtotal  '+ Cdbl(curdoc.SubTotal(0))
    Call uidoc.FieldSetText("GrandTotal",Format(total,"#,##0.00"))
    uidoc.refresh
    uidoc.gotofield"Item"
End Sub

Please help me. Thanks.

Upvotes: 0

Views: 300

Answers (2)

Richard Schwartz
Richard Schwartz

Reputation: 14628

Create a new hidden field called selectedCurrency. The initial value of this field should be empty.

In your Add button code, you need to first check selectedCurrency, and if it is blank you should set it equal to cur.

Then, also in the code for the Add button, you need to compare selectedCurrency and cur, and if they are not equal you should display your message box.

Upvotes: 1

D.Bugger
D.Bugger

Reputation: 2359

I'd fix the currency outside the code for the Add button, and also make it required before Add can be started.

Upvotes: 1

Related Questions