Merhaba arkadaşlar.
Aşağıdaki koda TextBox6 referans alınarak mükerrer kayıt yapmamak için gerekli düzenlemeyi yapamadım.
Aşağıdaki koda TextBox6 referans alınarak mükerrer kayıt yapmamak için gerekli düzenlemeyi yapamadım.
Kod:
Private Sub cmdKAYDET_Click()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim Satır As Long, k As Byte, S As Worksheet
Dim sor
Set S = ActiveSheet
Satır = S.Range("A65536").End(3).Row + 1
If TextBox7.Value = "" Then
TextBox7.SetFocus
MsgBox ("Lütfen Tarih Giriniz"), vbInformation, "s.s."
Exit Sub
End If
If ComboBox1.Value = "" Then
ComboBox1.SetFocus
MsgBox ("Lütfen 1.Nöbetçiyi Giriniz"), vbInformation, "s.s."
Exit Sub
End If
If ComboBox2.Value = "" Then
ComboBox2.SetFocus
sor = MsgBox("2.Nöbetçi girilmedi; yine de kayıt yapılsın mı?", vbYesNo, "s.s.")
If sor = vbNo Then Exit Sub
End If
If ComboBox1.Value = ComboBox2.Value Then
ComboBox2.SetFocus
MsgBox ("Her iki nöbetçi aynı kişi olamaz"), vbInformation, "s.s."
Exit Sub
End If
If TextBox6.Value = "" Then
TextBox6.SetFocus
MsgBox ("Lütfen Protokol Numarasını Giriniz"), vbInformation, "s.s."
Exit Sub
End If
If TextBox2.Value = "" Then
TextBox2.SetFocus
MsgBox ("Lütfen Çıkış Km sini Giriniz"), vbInformation, "s.s."
Exit Sub
End If
If TextBox3.Value = "" Then
TextBox3.SetFocus
MsgBox ("Lütfen Dönüş Km sini Giriniz"), vbInformation, "s.s."
Exit Sub
End If
If TextBox3 <> 0 And Val(TextBox3.Text) < Val(TextBox2.Text) Then
MsgBox ("Dönüş Km si Çıkış Km sinden Küçük Olamaz."), vbInformation, "s.s."
TextBox3.SetFocus
Exit Sub
End If
TextBox5.Text = Val(TextBox3) - Val(TextBox2)
S.Cells(Satır, "A").Value = TextBox7.Value 'Kayıt Tarihi
S.Cells(Satır, "A").HorizontalAlignment = xlCenter
S.Cells(Satır, "B").Value = TextBox6.Value 'pROTOKOL
S.Cells(Satır, "B").HorizontalAlignment = xlCenter
S.Cells(Satır, "C").Value = ComboBox1.Value 'Nöbetçi 1
S.Cells(Satır, "D").Value = ComboBox2.Value 'Nöbetçi 2
S.Cells(Satır, "BW").Value = TextBox2.Value 'Çıkış Km
S.Cells(Satır, "BX").Value = TextBox3.Value 'Dönüş Km
S.Cells(Satır, "BZ").Value = TextBox4.Value 'Alınan Yakıt
S.Cells(Satır, "BZ").NumberFormat = "#,##0.00"
S.Cells(Satır, "BY").Value = TextBox5.Value 'Yapılan Km
If OptionButton1.Value = True Then
S.Cells(Satır, "E").Value = "1"
S.Cells(Satır, "E").HorizontalAlignment = xlCenter
End If
End Sub
