Option Compare Database
Option Explicit
Private Sub erse_Click()
On Error Resume Next
delen
If (IsNumeric(order)) Then
DoCmd.RunCommand acCmdUndo
End If
DoCmd.GoToControl "id"
End Sub
Private Sub Form_Load()
Form.RecordSource = "pen"
Me.id.ControlSource = "nomer_sch1"
Me.order.ControlSource = "ID_IZM"
Me.Date.ControlSource = "DATA_OPL"
Me.enid.ControlSource = "IDENERGY"
Me.Gumar.ControlSource = "SUMA"
Dim r1
Dim r2
Dim r3
r1 = DLookup("[Usysdb]![db]", "Usysdb", "[Usysdb]![id]=" & (2))
r2 = DLookup("[UsysdbProtect]![dbz]", "Usysdbprotect", "[UsysdbProtect]![id]=" & (3))
r3 = DLookup("[UsysdbProtect]![dbx]", "Usysdbprotect", "[UsysdbProtect]![id]=" & (3))
If (r1 <> r2 And r1 <> r3) Then
Beep
MsgBox "Error 1001: Ask your administrator", vbOKOnly, ""
End If
Forms("en").Recordset.AddNew
Me.id.SetFocus
DoCmd.Maximize
End Sub
Private Sub id_AfterUpdate()
Dim dolg As Long
Me.aah = DLookup(" [eldb1]![fio] ", "eldb1", " [eldb1]![nomer_sch1] = " & Nz(Me.id, 0))
Me.adress = DLookup(" [eldb1]![adres] ", "eldb1", " [eldb1]![nomer_sch1] = " & Nz([id], 0)) & " " & DLookup(" [eldb1]![dom] ", "eldb1", " [eldb1]![nomer_sch1] = " & Nz([id], 0)) & " " & DLookup(" [eldb1]![kvartira] ", "eldb1", " [eldb1]![nomer_sch1] = " & Nz([id], 0))
Me.cuc = DLookup(" [eldb2]![pokazpr] ", "eldb2", " [eldb2]![nomer_sch] = " & Nz([id], 0)) & " | " & DLookup(" [eldb2]![pokaz] ", "eldb2", " [eldb2]![nomer_sch] = " & Nz([id], 0))
Me.rasx = DLookup(" [eldb2]![suma] ", "eldb2", " [eldb2]![nomer_sch] = " & Nz([id], 0)) & [t1] & DLookup(" [eldb2]![data_opl] ", "eldb2", " [eldb2]![nomer_sch] = " & Nz([id], 0))
Me.rasxdram = DLookup(" [eldb2]![raznica] ", "eldb2", " [eldb2]![nomer_sch] = " & Nz([id], 0)) & t4 & DLookup(" [eldb2]![raznicasum] ", "eldb2", " [eldb2]![nomer_sch] = " & Nz([id], 0)) & t3 & DLookup(" [eldb2]![tar] ", "eldb2", " [eldb2]![nomer_sch] = " & Nz([id], 0)) & t2
dolg = DLookup(" [eldb2]![dolg] ", "eldb2", " [eldb2]![nomer_sch] = " & Nz([id], 0))
If ([dolg] < 0) Then
Me.hh = (-[dolg]) & t5
End If
If ([dolg] > 0) Then
Me.hh = [dolg] & t6
End If
If ([dolg] = 0) Then
Me.hh = [dolg] & t7
End If
End Sub
Private Sub save___print_Click()
If (IsNull(id)) Or (id = 0) Or (id < 0) Then
Beep
MsgBox "Ââåäèòå àáîíåíòñêèé íîìåð", vbInformation, ""
DoCmd.GoToControl "id"
Exit Sub
End If
If (IsNull(aah) And IsNull(adress)) Or (IsError(aah) And IsError(adress)) Then
Beep
MsgBox "Àáîíåíòñêèé íîìåð îòñóñòâóåò", vbInformation, ""
DoCmd.GoToControl "id"
Exit Sub
End If
If (IsNull(Gumar)) Or (Gumar = 0) Or (Gumar < 0) Then
Beep
MsgBox "Ââåäèòå ñóììó", vbInformation, ""
DoCmd.GoToControl "gumar"
Exit Sub
End If
If (Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
End If
Me.enid = DLookup(" [usertmp]![userid] ", "usertmp", " [usertmp]![id] = " & 1)
DoCmd.OpenQuery "ensumadd", acViewNormal, acAdd
DoCmd.OpenReport "enandor", acViewNormal, "", "", acNormal
delen
Forms("en").Recordset.AddNew
Me.id.SetFocus
End Sub
Private Sub save___print_KeyPress(KeyAscii As Integer)
If (IsNull(id)) Or (id = 0) Or (id < 0) Then
Beep
MsgBox "Ââåäèòå àáîíåíòñêèé íîìåð", vbInformation, ""
DoCmd.GoToControl "id"
Exit Sub
End If
If (IsNull(aah) And IsNull(adress)) Or (IsError(aah) And IsError(adress)) Then
Beep
MsgBox "Àáîíåíòñêèé íîìåð îòñóñòâóåò", vbInformation, ""
DoCmd.GoToControl "id"
Exit Sub
End If
If (IsNull(Gumar)) Or (Gumar = 0) Or (Gumar < 0) Then
Beep
MsgBox "Ââåäèòå ñóììó", vbInformation, ""
DoCmd.GoToControl "gumar"
Exit Sub
End If
If (Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
End If
Me.enid = DLookup(" [usertmp]![userid] ", "usertmp", " [usertmp]![id] = " & 1)
DoCmd.OpenQuery "ensumadd", acViewNormal, acAdd
DoCmd.OpenReport "enandor", acViewNormal, "", "", acNormal
delen
Forms("en").Recordset.AddNew
Me.id.SetFocus
End Sub
Private Sub Gumar_Click()
If (IsNull(id)) Or (id = 0) Or (id < 0) Then
Beep
MsgBox "Ââåäèòå àáîíåíòñêèé íîìåð", vbInformation, ""
DoCmd.GoToControl "id"
Exit Sub
End If
If (IsNull(aah) And IsNull(adress)) Or (IsError(aah) And IsError(adress)) Then
Beep
MsgBox "Àáîíåíòñêèé íîìåð îòñóñòâóåò", vbInformation, ""
DoCmd.GoToControl "id"
Exit Sub
End If
End Sub
Private Sub Gumar_KeyPress(KeyAscii As Integer)
If (IsNull(id)) Or (id = 0) Or (id < 0) Then
Beep
MsgBox "Ââåäèòå àáîíåíòñêèé íîìåð", vbInformation, ""
DoCmd.GoToControl "id"
Exit Sub
End If
If (IsNull(aah) And IsNull(adress)) Or (IsError(aah) And IsError(adress)) Then
Beep
MsgBox "Àáîíåíòñêèé íîìåð îòñóñòâóåò", vbInformation, ""
DoCmd.GoToControl "id"
Exit Sub
End If
End Sub
Private Sub only_save_Click()
If (IsNull(id)) Or (id = 0) Or (id < 0) Then
Beep
MsgBox "Ñ íà÷àëà ââåäèòå èìÿ", vbInformation, ""
DoCmd.GoToControl "id"
Exit Sub
End If
If (IsNull(aah) And IsNull(adress)) Or (IsError(aah) And IsError(adress)) Then
Beep
MsgBox "Àáîíåíòñêèé íîìåð îòñóñòâóåò", vbInformation, ""
DoCmd.GoToControl "id"
Exit Sub
End If
If (IsNull(Gumar)) Or (Gumar = 0) Or (Gumar < 0) Then
Beep
MsgBox "Ââåäèòå ñóììó", vbInformation, ""
DoCmd.GoToControl "gumar"
Exit Sub
End If
If (Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
End If
Me.enid = DLookup(" [usertmp]![userid] ", "usertmp", " [usertmp]![id] = " & 1)
DoCmd.OpenQuery "ensumadd", acViewNormal, acAdd
delen
DoCmd.GoToRecord acForm, "en", acNewRec
DoCmd.GoToControl "id"
End Sub
Private Sub Command289_Click()
If (IsNumeric(order)) Then
DoCmd.RunCommand acCmdUndo
End If
DoCmd.Close acForm, "en"
DoCmd.OpenForm "finden", acNormal, "", "", , acNormal
End Sub
|