Hello, I would ask please if anyone can answer this question because I really need to implement this functionality. regards, Yessica
2013/2/6 Yessica Brinkmann <yessica.brinkm...@gmail.com> > Hello. > I have a form that has a subform Sales sales detail. I have two macros, a > call ponerCampos to paste the value of the price of the goods by the id in > the subform detail, and another macro call calcularTotalVentas associated > with a Calculate Total button on the same form, which calculates the > total amount the sale. It's very strange but everything works fine when I > modify the amount of all records except the first. But when I change the > amount of the first record, for example if I put number 2 instead of 1 say > in the amount, and then I press the Calculate Total button, It change the > amount to the previous value. The scheme does not work when the detail has > a single record, it is the same. Much appreciate a response. Regards, > Yessica > My macros are: > > Sub PonerCampos( Evento ) > Dim sSel As String > Dim oFrm As Object > Dim oConcepto As Object > Dim oPrecio As Object > Dim oCon As Object > Dim oStat As Object > Dim sSQL As String > Dim oRes As Object > > oFrm = Evento.Source.Model.Parent > Dim oCtrl As Object > oCtrl = oFrm.Parent.Parent.GetByName("datfecha") > oCtrl = > oFrm.Parent.Parent.Parent.Parent.CurrentController.GetControl(oCtrl) > oCtrl.SetFocus > Wait(0) > > sSel = Evento.Source.Model.BoundField.Value > oConcepto = oFrm.getByName("id_producto") > oPrecio = oFrm.getByName ("precio") > oCon = ThisDatabaseDocument.CurrentController.ActiveConnection > oStat = oCon.CreateStatement > > > sSQL = "SELECT precio_final FROM mercaderia WHERE id_producto='" & sSel > &"'" > > oRes = oStat.ExecuteQuery(sSQL) > If oRes.next Then > > > oPrecio.BoundField.Value=oRes.getDouble(1) > Else > > oPrecio.BoundField.Value=0 > End If > > > oCtrl=oFrm.Parent.Parent.Parent.Parent.CurrentController.GetControl(oFrm) > oCtrl.SetFocus > End Sub > > > Sub CalcularTotalVentas( Evento ) > Dim oFormulario As Object > Dim oSubFormulario As Object > Dim oGridComposicion As Object > Dim oTotal As Object > Dim oCantidad As Object > Dim oPrecio As Object > Dim fParcial As Double > Dim fTotal As Double > Dim co1 As Byte > Dim co2 As Byte > > > oFormulario = Evento.Source.getModel.getParent() > > oTotal = oFormulario.getByName("fmttotal") > > oSubFormulario = oFormulario.getByName("SubForm") > > oGridComposicion = oSubFormulario.getByName("SubForm_Grid") > > oCantidad = oGridComposicion.getByName("cantidad") > > oPrecio = oGridComposicion.getByName("precio") > > > oSubFormulario.first() > Do > fParcial = oCantidad.getCurrentValue()*oPrecio.getCurrentValue() > > fTotal = fTotal + fParcial > > oSubFormulario.next() > Loop Until oSubFormulario.isAfterLast() > oTotal=oFormulario.getByName("fmttotal") > oTotal.BoundField.UpdateFloat(fTotal) > oSubFormulario.Reload > End Sub >