Results 1 to 4 of 4

Thread: cannot update record from MSHFlexgrid..help!!!

  1. #1

    Thread Starter
    Hyperactive Member Apek's Avatar
    Join Date
    Aug 2002
    Location
    Kg Melayu,2 33 °N,102 10 °E
    Posts
    283

    cannot update record from MSHFlexgrid..help!!!

    i want to update certain records from my mshflexgrid.
    but i get the error "field cannot be updated".
    Why??

    this is my code to update:
    VB Code:
    1. Dim i
    2. With mshRejLot
    3. For i = 1 To rs.RecordCount
    4.     .TextMatrix(i, 0) = i
    5. 'mshRejLot.TextMatrix(i, 4) = Format(rs!amount, "dd/MM/yyyy")
    6.     .TextMatrix(i, 7) = Round(rs!amount, 2)
    7.     .TextMatrix(i, 8) = Round(rs!Origin_Cost, 2)
    8.     'rs.Find "rs!JOB_NO = '" & .TextMatrix(i, 2) & "'"
    9.     rs("AMOUNT") = Round(.TextMatrix(i, 7), 2)
    10.     rs("ORIGIN_COST") = Format$(Round(.TextMatrix(i, 8), 2), "Currency")
    11.     rs.Update
    12.     If .TextMatrix(i, 7) = "" Then
    13.         .Row = i
    14.         .Col = 7
    15.         .CellBackColor = vbRed
    16.         .Row = i
    17.         .Col = 8
    18.         .CellBackColor = vbRed
    19.     End If
    20.     Dim k
    21.     'For k = 1 To rs.RecordCount
    22.     'rs.Find "rs!JOB_NO = '" & .TextMatrix(i, 2) & "'"
    23.  
    24. rs.MoveNext
    25.     'Next k
    26. Next i
    27. End With

    and this is my sql statement:
    VB Code:
    1. rs.Open "SELECT REJECT_LOT.PART_CODE, REJECT_LOT.JOB_NO, REJECT_LOT.SCRAP," & _
    2.         "REJECT_LOT.TRANS_DATE, REJECT_LOT.REASON,REJECT_LOT.DETAIL," & _
    3.         "(([REJECT_LOT].[SCRAP]/1000)*[Cost_Price].[Origin_Cost]) AS AMOUNT," & _
    4.         "Cost_Price.Origin_Cost FROM Cost_Price " & _
    5.         "RIGHT JOIN REJECT_LOT ON Cost_Price.Part_Code = REJECT_LOT.PART_CODE WHERE" & _
    6.         "(((REJECT_LOT.TRANS_DATE)BETWEEN #" & dari & "# And #" & hingga & "#)" & _
    7.         "AND ((REJECT_LOT.REASON)='DDI'))", conn, adOpenKeyset, adLockOptimistic

    please HELP!!!!
    "The reason you see open source there at all is because we came in and said there should be a platform that's identical with millions and millions of machines."
    Get it HERE


    Regards..
    Apek

  2. #2
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 2001
    Location
    New Delhi , INDIA
    Posts
    858
    You Cannnot update a calculated field .... 'amount '
    Vishal Marya, MCP .net 3.5
    My Site
    http://www.vstoolsgallery.com/
    http://visualstudiogallery.msdn.micr...b-f87a909b9266





    Please indicate what version of vb you use.
    Please mark your thread resolved using the Thread Tools above.
    -----------------------------------------

  3. #3

    Thread Starter
    Hyperactive Member Apek's Avatar
    Join Date
    Aug 2002
    Location
    Kg Melayu,2 33 °N,102 10 °E
    Posts
    283
    if cannot, can u give me a way/code to update it???
    dont just say cannot...
    thanks..
    "The reason you see open source there at all is because we came in and said there should be a platform that's identical with millions and millions of machines."
    Get it HERE


    Regards..
    Apek

  4. #4
    Hyperactive Member dRAMmer's Avatar
    Join Date
    Oct 2001
    Location
    strangelans
    Posts
    463
    hi Apek!

    let's just say for a while the AMOUNT is not a calculated field, why is it in your code you put the AMOUNT in the grid and without changing anything you save it back?

    the solution to your problem would be to include in your SELECT statement the fields that are used for the calculation of AMOUNT hide it in the grid (if you don't want the users to see it) and from whereever in your program you get the values for those fields, save it.

    like this: upadte [REJECT_LOT].[SCRAP] and [Cost_Price].[Origin_Cost]
    and refresh your grid
    live, code and die...

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