' Ova ide na taster NOVI na forma frmZagPutniNalogSve
Private Sub cmdNovi_Click()
On Error GoTo err_cmdNovi_Click
Dim db As Database
Dim rs As Recordset
Dim bA As Long
Dim bB As Long
Dim bPlus As Integer
bPlus = 1
subProverka:
bA = Nz(DMax("[ZPN_NALOG]", "tblZagPutniNalog"), 0) + bPlus
bB = Nz(DMax("[ZPN_BROJ]", "tblZagPutniNalog"), 0) + bPlus
bPlus = bPlus + 1
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM tblBrojeve WHERE bZPN_NALOG=" & bA & " AND bZPN_BROJ=" & bB)
If rs.RecordCount = 0 Then
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblBrojeve (bZPN_NALOG,bZPN_BROJ) VALUES(" & bA & "," & bB & ")"
DoCmd.SetWarnings True
DoCmd.OpenForm "frmZagPutniNalog", , , , acFormAdd
Forms!frmZagPutniNalog!ZPN_NALOG = bA
Forms!frmZagPutniNalog!ZPN_BROJ = bB
Else
GoTo subProverka
End If
exit_cmdNovi_Click:
Exit Sub
err_cmdNovi_Click:
MsgBox Err.Description
Resume exit_cmdNovi_Click
End Sub
' Ovo dole zamenis u frmZagPutniNalog
Private Sub Form_Current()
If Me.NewRecord Then
Me.Caption = "PUTNI NALOG - NOVI UNOS"
Me.AllowAdditions = True
Me.ZPN_NALOG.Enabled = True
Me.ZPN_RA.SetFocus
'Me.LOCK_USER = M_Oper.OperID
'Me.LOCK_TIME = Now()
'Me.lblVD.Caption = ""
Me.lblRA.Caption = ""
Me.lblOS.Caption = ""
Me.lblRE.Caption = ""
Else
If Not IsNull(Me.ZPN_VD) Then
Me.lblVD.Caption = Me.ZPN_VD.Column(1)
Else
Me.lblVD.Caption = ""
End If
If Not IsNull(Me.ZPN_RA) Then
Me.lblRA.Caption = Me.ZPN_RA.Column(1) & " " & Me.ZPN_RA.Column(2)
Else
Me.lblRA.Caption = ""
End If
If Not IsNull(Me.ZPN_OS) Then
Me.lblOS.Caption = Me.ZPN_OS.Column(1)
Else
Me.lblOS.Caption = ""
End If
If Not IsNull(Me.ZPN_RE) Then
Me.lblRE.Caption = Me.ZPN_RE.Column(1)
Else
Me.lblRE.Caption = ""
End If
If Me.ZPN_KNJIZEN = -1 Then
Me.Caption = "PUTNI NALOG - KNJIZEN - PREGLED"
Me.AllowAdditions = False
Me.AllowEdits = False
Me.AllowDeletions = False
'Me.Stav.Enabled = False
Me.cmdKNJIZENJE.Enabled = False
Me.cmdBrisanje.Enabled = False
Me.cmdZatvori.Enabled = True
Me.cmdSnimi.Enabled = False
Me.cmdPonisti.Enabled = False
Me.Command39.Enabled = False
'Me.Command47.Enabled = False
Me.Stav.Form.AllowAdditions = False
Me.Stav1.Form.AllowAdditions = False
Me.Stav2.Form.AllowAdditions = False
Me.Stav.Form.AllowEdits = False
Me.Stav1.Form.AllowEdits = False
Me.Stav2.Form.AllowEdits = False
Me.Stav.Form.AllowDeletions = False
Me.Stav1.Form.AllowDeletions = False
Me.Stav2.Form.AllowDeletions = False
Me.Stav4.Form.AllowAdditions = False
Me.Stav5.Form.AllowAdditions = False
Me.Stav6.Form.AllowAdditions = False
Me.Stav4.Form.AllowEdits = False
Me.Stav5.Form.AllowEdits = False
Me.Stav6.Form.AllowEdits = False
Me.Stav4.Form.AllowDeletions = False
Me.Stav5.Form.AllowDeletions = False
Me.Stav6.Form.AllowDeletions = False
Me.Stav7.Form.AllowAdditions = False
Me.Stav7.Form.AllowEdits = False
Me.Stav7.Form.AllowDeletions = False
Me.Stav3.Form.AllowAdditions = False
Me.Stav3.Form.AllowEdits = False
Me.Stav3.Form.AllowDeletions = False
Else
Me.Caption = "PUTNI NALOG - IZMENE/BRISANJE " & Me.ZPN_NALOG
Me.AllowAdditions = True
Me.AllowDeletions = True
Me.AllowEdits = True
Me.Stav.Enabled = True
Me.ZPN_NALOG.Enabled = True
Me.cmdKNJIZENJE.Enabled = True
Me.cmdBrisanje.Enabled = True
Me.cmdZatvori.Enabled = True
Me.cmdSnimi.Enabled = True
Me.cmdPonisti.Enabled = True
Me.Command39.Enabled = True
'Me.Command47.Enabled = True
Me.Stav.Form.AllowAdditions = True
Me.Stav1.Form.AllowAdditions = True
Me.Stav2.Form.AllowAdditions = True
Me.Stav.Form.AllowEdits = True
Me.Stav1.Form.AllowEdits = True
Me.Stav2.Form.AllowEdits = True
Me.Stav.Form.AllowDeletions = True
Me.Stav1.Form.AllowDeletions = True
Me.Stav2.Form.AllowDeletions = True
Me.Stav4.Form.AllowAdditions = True
Me.Stav5.Form.AllowAdditions = True
Me.Stav6.Form.AllowAdditions = True
Me.Stav4.Form.AllowEdits = True
Me.Stav5.Form.AllowEdits = True
Me.Stav6.Form.AllowEdits = True
Me.Stav4.Form.AllowDeletions = True
Me.Stav5.Form.AllowDeletions = True
Me.Stav6.Form.AllowDeletions = True
Me.Stav7.Form.AllowAdditions = True
Me.Stav7.Form.AllowEdits = True
Me.Stav7.Form.AllowDeletions = True
Me.Stav3.Form.AllowAdditions = True
Me.Stav3.Form.AllowEdits = True
Me.Stav3.Form.AllowDeletions = True
End If
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * FROM tblBrojeve WHERE bZPN_NALOG=" & ZPN_NALOG & " AND bZPN_BROJ=" & ZPN_BROJ
DoCmd.SetWarnings True
End Sub