ok ecco il codice
EVENTO DEL TASTO "ELIMINA"
codice:
Private Sub cmdElimina_Click()
On Error GoTo errore
Dim ob As Control
If DE.rscmdS.BOF Or DE.rscmdS.EOF Then
MsgBox "Nessuna scheda selezionata"
Exit Sub
End If
If MsgBox("Sicuro di eliminare la scheda?", vbYesNo, "Eliminazione scheda") = 6 Then
DE.rscmdS.Delete
If DE.rscmdS.RecordCount = 0 Then
'Pulizia dei campi
For Each ob In Me.Controls
If (TypeOf ob Is TextBox) Or (TypeOf ob Is ComboBox) Then
ob.Text = ""
End If
If (TypeOf ob Is CheckBox) Then
ob.Value = False
End If
If (TypeOf ob Is DTPicker) Then
ob.Value = Date
ob.Value = Null
End If
Next
lblLogin(0).Caption = ""
lblLogin(1).Caption = ""
Else
Call cmdMove_Click(1)
End If
End If
errore:
If Err.Number <> 0 Then MsgBox Err.Number & vbCrLf & Err.Description
End Sub
EVENTO DEL TASTO "NUOVO"
codice:
Private Sub cmdNuovo_Click()
Dim ob As Control
Dim N As Integer
If Not (DE.rscmdS.EOF And DE.rscmdS.BOF) Then
If DE.rscmdS.EditMode = adEditAdd Or DE.rscmdS.EditMode = adEditInProgress Then
MsgBox "Prima salvare il record corrente!", vbCritical, "Attenzione"
Exit Sub
End If
End If
'Assegna il numero alla schedamscbox
If DE.rscmdS.RecordCount = 0 Then
DE.rscmdS.AddNew
txtN = 1
Else
DE.rscmdS.MoveLast
N = DE.rscmdS(0) + 1
DE.rscmdS.AddNew
txtN = N
End If
'Pulizia dei campi
For Each ob In Me.Controls
If (TypeOf ob Is TextBox) Or (TypeOf ob Is ComboBox) Then
If ob.Name <> "txtN" Then ob.Text = ""
End If
If (TypeOf ob Is CheckBox) Then
ob.Value = False
End If
If (TypeOf ob Is DTPicker) Then
ob.Value = Date
ob.Value = Null
End If
Next
cmdSalva.Enabled = True
End Sub