Private Sub sav_Click() DoCmd.Beep DoCmd.SetWarnings False If MsgBox("سوف يتم حفظ الفاتورة بعد طباعتها. تريد بالفعل اكمال العملية ", vbYesNo + vbInformation + vbMsgBoxRight + vbDefaultButton1, "تنبيـــه") = vbNo Then DoCmd.RunCommand acCmdDeleteRecord SendKeys "{ESC}" MsgBox "لقد تم إلغاء عملية الطباعة والحفظ ", vbMsgBoxRight + vbInformation, "" Refresh DoCmd.close ElseIf (DLookup("[s]", "Torderno", "[orderno]=" & Me.orderno) = True) Then MsgBox " خطــأ... الفاتورة محفوظة من قبل ", vbCritical, " خطــأ 1 " DoCmd.CancelEvent DoCmd.close ElseIf IsNull(DLookup("[orderno]", "Torder", "[orderno]=" & Me.orderno)) Then MsgBox " خطــأ... لا يوجد اصناف بالفاتورة ", vbCritical, " خطــأ 2 " DoCmd.CancelEvent DoCmd.close ElseIf Me.num > 0 Then MsgBox " خطــأ... لم يتم الانتقال الي فاتورة جديدة ", vbCritical, " خطــأ 3 " DoCmd.CancelEvent DoCmd.close ElseIf IsNull(Me.totalinvoice) Or IsNull(Me.itemcount) Then MsgBox "ادخل اصناف الفاتورة ", vbInformation, " " Me.F_ordersubform.SetFocus ElseIf (Me.totalinvoice) = 0 Then MsgBox "ادخل اصناف الفاتورة ", vbInformation, " " Me.F_ordersubform.SetFocus ElseIf IsNull([F_ordersubform]![Qty]) And ([F_ordersubform]![itemcode]) > 0 Then MsgBox "ادخل العدد ", vbInformation, " " Me.F_ordersubform.SetFocus [F_ordersubform]![Qty].SetFocus ElseIf Me.discount > Me.totalinvoice Or Me.totalinvoice < 0 Then MsgBox "مبلغ الخصم اكبر من مبلغ الفاتورة ...! ", vbCritical, " خطــــأ " Me.discount = 0 Me.cash.SetFocus Me.discount.SetFocus Else DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 Me.tim.Value = format(Time, "hh:mm AMPM") Me.cashier = USID Me.due = Me.amount Me.num.Value = format([orderno], "0000000") Refresh Set Q = CurrentDb.OpenRecordset("SELECT torderno.orderno, torderno.s FROM [torderno] where s=false;") Q.edit Q!s = True Q.Update Refresh DoCmd.OpenReport "s", acViewNormal, , "[orderno] = " & Me![orderno] Refresh DoCmd.GoToRecord , , acNewRec If Me.orderno > 0 Then DoCmd.close Exit Sub Else Refresh Call MyOutoNum F_ordersubform.SetFocus DoCmd.GoToControl "itemcode" Refresh End If End If Exit Sub