Working with AccessDataSource Update Event RRS feed

  • Question

  • User-72198832 posted

    I have three Numeric columns:  LastMeter, NewInput, UsageInput on a bound datagrid

    When editing NewInput I would like to display value of NewInput - LastMeter in UsageInput Column

    Example:  LastMeter=1000, MeterInput=1200, UsageInput is calculated value of 200

    Once I trap the AccessDataSource Update event, how do I access these fields and put the calculated result in the Update Event SQL?

    Unmodified Update SQL is as follows:

    UPDATE [EquipmentUsage] SET [EquipName] = ?, [EquipGroup] = ?, [UsageYTD] = ?, [LastMeter] = ?, [MeterInput] = ?, [UsageInput] = ? WHERE [EquipID] = ?

    Need something like:

    Private Sub AccessDataSource1_Updating(.....)    'Trapped Update Event

             IF MeterInput > LastMeter Then   'how do I access these values

                 UsageInput = MeterInput - LastMeter   'and how to replace calculated value

                AccessDataSource1.UpdateCommand= ?????  'do I need to change the Update command?

            End If

        End Sub

    End If

         Again, All help is appreciated.



    Saturday, November 6, 2010 11:03 AM


  • User-72198832 posted

    Got it to work.... here's what I did.


        Private Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
            If e.NewValues("MeterInput") > e.NewValues("LastMeter") Then
                e.NewValues("UsageInput") = e.NewValues("MeterInput") - e.NewValues("LastMeter")
            End If
        End Sub

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 7, 2010 12:30 AM