ESEMPIO AGGIORNAMENTO DATI RECORDSET CICLO

Di piĆ¹
10 Mesi 2 Settimane fa #698 da fabioM1
fabioM1 ha creato la discussione ESEMPIO AGGIORNAMENTO DATI RECORDSET CICLO
Public Sub RicalcolaLavDX(idscheda As Integer, DXsel As Integer, Default As Integer, CUomo As Variant, CIsola As Variant, CComb As Variant, CSabb As Variant)
Dim dtime As Variant
Dim strselect As String
Dim DBCorrente1 As DAO.Database
Dim RS1 As DAO.Recordset

strselect = "SELECT * FROM lavorazioni_schede WHERE idscheda =" & idscheda & " and DX=" & DXsel & " and fl_default=" & Default

Set DBCorrente1 = CurrentDb
Set RS1 = DBCorrente1.OpenRecordset(strselect, dbOpenDynaset)


TOTMINLAV = 0
TOTSECLAV = 0
PRICETOT = 0

RS1.MoveFirst


Do While Not RS1.EOF
RS1.Edit

'ricalcola_riga
If RS1!prod > 0 Then


RS1!mm_prodc = extract_minuti(RS1!prod)
RS1!ss_prodc = extract_secondi(RS1!prod)

Else

RS1!mm_prodc = 0
RS1!ss_prodc = 0

End If




RS1!fl1 = RS1!fl1 + 1

If RS1!prod_costi = 0 Then RS1!prezzo = 0

Select Case RS1!tipo_lav_costo

Case 0
If RS1!prod_costi > 0 Then
If CUomo = 0 Then
'MsgBox "Costo lavorazione mancante - IMPOSSIBILE CALCOLARE", vbOKOnly Or vbExclamation, "DATO MANCANTE"
Else
RS1!prezzo = Round(CUomo / RS1!prod_costi, 4)
End If
End If


Case 1
If RS1!prod_costi > 0 Then
If CIsola = 0 Then
'MsgBox "Costo lavorazione mancante - IMPOSSIBILE CALCOLARE", vbOKOnly Or vbExclamation, "DATO MANCANTE"
Else
RS1!prezzo = Round(CIsola / RS1!prod_costi, 4)
End If
End If


Case 2
If RS1!prod_costi > 0 Then
If CComb = 0 Then
'MsgBox "Costo lavorazione mancante - IMPOSSIBILE CALCOLARE", vbOKOnly Or vbExclamation, "DATO MANCANTE"
Else
RS1!prezzo = Round(CComb / RS1!prod_costi, 4)
End If
End If


Case 3

If RS1!prod_costi > 0 Then
If CSabb = 0 Then
'MsgBox "Costo lavorazione mancante - IMPOSSIBILE CALCOLARE", vbOKOnly Or vbExclamation, "DATO MANCANTE"
Else
RS1!prezzo = Round(CSabb / RS1!prod_costi, 4)
End If
End If


End Select


'RS1!mm_prodc = 0
'RS1!ss_prodc = 0

TOTMINLAV = TOTMINLAV + RS1!mm_prodc
TOTSECLAV = TOTSECLAV + RS1!ss_prodc
PRICETOT = PRICETOT + RS1!prezzo




RS1.Update
RS1.MoveNext
Loop



dtime = TOTMINLAV * 60 + TOTSECLAV
dtime = dtime / 86400



MMPROD = Format(dtime, "nn")
SSPROD = Format(dtime, "ss")
'PRICETOT

RS1.Close
DBCorrente1.Close


End Sub

Si prega Accedi a partecipare alla conversazione.

Tempo creazione pagina: 0.099 secondi
Powered by Forum Kunena