Results 1 to 9 of 9

Thread: DAO Update - Error - Very Urgent

  1. #1

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Question DAO Update - Error - Very Urgent

    This is my code...There is no error reported, but the table is not updated...someone pls help me.



    Sub PmtUpdateCurrencyRate(CtrlNbr As Long, RptNbr As Long)
    Dim rsCurRate As Recordset
    Dim sSQL As String
    Dim sUpdateSQL As String
    Dim uCurCRate As Double ' store currency conversion rate
    Dim uITotal As Double ' store Invoice Total
    Dim lVendID As Long ' store vendor id
    Dim dIDate As Date ' store Invoice Date

    On Error GoTo errhandler

    Set db = CurrentDb

    sSQL = "SELECT DISTINCT TBL_INVHDR.ORDERNBR as InvHdrOrdNbr, " & _
    "TBL_INVHDR.RELEASENBR as InvHdrRelNbr, " & _
    "TBL_INVHDR.INVOICENBR as InvHdrInvNbr, " & _
    "TBL_INVHDR.VENDORID as InvHdrVendorId, " & _
    "TBL_INVHDR.INVTOTAL as InvHdrInvTotal, " & _
    "TBL_INVHDR.INVDATE as InvHdrInvDte, " & _
    "TBL_INVHDR.VENDOR as InvHdrVendor, " & _
    "CurConvRate.Currency_Per_Rate as CCRate " & _
    "FROM TBL_INVHDR, TBL_VENDORS, CurConvRate WHERE " & _
    "TBL_INVHDR.PROC_AP = 0 AND TBL_INVHDR.DISTRIBUTION = 1 AND " & _
    "TBL_INVHDR.CONTROLNBR = " & CtrlNbr & " AND " & _
    "TBL_INVHDR.REPORTNBR = " & RptNbr & " AND " & _
    "TBL_INVHDR.VendorId = TBL_VENDORS.VendorId AND " & _
    "TBL_VENDORS.Currency_Code = CurConvRate.Currency_Code_Source and " & _
    "format(CurConvRate.Currency_Rate_Effective_Date,'mm/dd/yyyy') = format(TBL_INVHDR.INVDATE,'mm/dd/yyyy') ;"

    Set rsCurRate = db.OpenRecordset(sSQL, DB_OPEN_DYNASET)

    With rsCurRate
    If Not (.BOF And .EOF) Then
    .MoveFirst
    Do While Not .EOF
    MsgBox .Fields("InvHdrVendorId")
    uCurCRate = .Fields("CCRate")
    uITotal = .Fields("InvHdrInvTotal") * .Fields("CCRate")
    lVendID = .Fields("InvHdrVendorId")
    dIDate = .Fields("InvHdrInvDte")
    'sUpdateSQL = "UPDATE TBL_INVHDR SET Cur_Conv_Rate = " & uCurCRate & ", " & _
    ' "Invtotal_USD = " & uITotal & " " & _
    ' "WHERE VENDORID = " & lVendID & " " & _
    ' "AND format(INVDATE,'mm/dd/yyyy') = #" & Format(dIDate, "mm/dd/yyyy") & "# ;"
    ws.BeginTrans
    db.Execute "UPDATE TBL_INVHDR SET Cur_Conv_Rate = " & uCurCRate & ", " & _
    "Invtotal_USD = " & uITotal & " " & _
    "WHERE VENDORID = " & lVendID & " " & _
    "AND INVDATE = #" & dIDate & "#;", dbFailOnError
    ws.CommitTrans
    .MoveNext
    Loop
    End If
    End With

    Exit Sub
    errhandler:
    MsgBox Err.DESCRIPTION
    End Sub
    Thanks and Regards,
    Venkat.

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284
    Db, that is database doesn't have a edit or update property/method. Only the recordset has.
    Infact the db.excute can be given withing workspace.begintrans and workspace.committrans. I tried that also. It didn't work.

    I know I am making some mistake I am not able to trace it.
    Thanks and Regards,
    Venkat.

  4. #4

  5. #5

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284
    I am sorry for that har formattings....I tried using the debugger....The query string and all came out perfectly..still couldnt guess whats the problem.
    Thanks and Regards,
    Venkat.

  6. #6

  7. #7

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284
    Yep.....
    there was no clue abt the bug..

    any more suggestions?
    Thanks and Regards,
    Venkat.

  8. #8
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Try substituting this for your db.Execute statement

    db.Execute "UPDATE TBL_INVHDR SET Cur_Conv_Rate = '" & uCurCRate & "', " & _
    "Invtotal_USD = '" & uITotal & "' " & _
    "WHERE VENDORID = '" & lVendID & "' " & _
    "AND INVDATE = #'" & dIDate & "'#;", dbFailOnError

    Other than that I'm out of ideas.

  9. #9

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Smile

    Hi Martin,

    Thats ok..thanks for ur help...

    Will try this anyway.
    Rgds
    Venkat.
    Thanks and Regards,
    Venkat.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width