ถึงท่านอาจารย์ สันติสุข ค่ะ
กระทู้เก่าบอร์ด อ.Yeadram

 55,181   91
URL.หัวข้อ / URL
ถึงท่านอาจารย์ สันติสุข ค่ะ

คำถามต่อเนื่องนะคะอาจารย์ พอดีที่หนูหายไปหนูแอบไปรับปริญญามาค่ะ
ข้อที่ 1 เรื่องการค้นหาข้อมูลจากกล่องComboค่ะ

หนูได้นำCodeที่อาจารย์ให้ไปวางตามนี้ค่ะ

Option Compare Database
Option Explicit


Sub SetDefaultShippingAddress()
    If IsNull(Me![Customer ID]) Then
        ClearShippingAddress
    Else
       
        Dim rsw As New RecordsetWrapper
        If rsw.OpenRecordset("Customers Extended", "[ID] = " & Me.Customer_ID) Then
        Me.[InvoiceNO] = DMax("[InvoiceNumber]", "[Orders]") + 1
            With rsw.Recordset
               Me![Ship Name] = ![Contact Name]
               Me![Ship Address] = ![Address]
               End With
        End If
    End If
End Sub


Private Sub cmdDeleteOrder_Click()
    If IsNull(Me![Order ID]) Then
        Beep
    ElseIf Me![Status ID] = Shipped_CustomerOrder Or Me![Status ID] = Closed_CustomerOrder Then
        MsgBoxOKOnly CannotCancelShippedOrder
    ElseIf MsgBoxYesNo(CancelOrderConfirmPrompt) Then
        If CustomerOrders.Delete(Me![Order ID]) Then
            MsgBoxOKOnly CancelOrderSuccess
            eh.TryToCloseObject
        Else
            MsgBoxOKOnly CancelOrderFailure
        End If
    End If
End Sub


Private Sub cmdClearAddress_Click()
    ClearShippingAddress
End Sub


Private Sub ClearShippingAddress()
    Me![Ship Name] = Null
    Me![Ship Address] = Null
    Me![Ship City] = Null
    Me![Ship State/Province] = Null
    Me![Ship ZIP/Postal Code] = Null
    Me![Ship Country/Region] = Null
End Sub


Private Sub cmdCompleteOrder_Click()
    If Me![Status ID] <> Shipped_CustomerOrder Then
        MsgBoxOKOnly OrderMustBeShippedToClose
    ElseIf ValidateOrder(Closed_CustomerOrder) Then
        Me![Status ID] = Closed_CustomerOrder
        eh.TryToSaveRecord
        MsgBoxOKOnly OrderMarkedClosed
        SetFormState
    
    End If
End Sub


Private Sub cmdCreateInvoice_Click()
    Dim OrderID As Long
    Dim InvoiceID As Long

    OrderID = Nz(Me![Order ID], 0)
    
    ' Gracefully exit if invoice already created
    If CustomerOrders.IsInvoiced(OrderID) Then
        If MsgBoxYesNo(OrderAlreadyInvoiced) Then
       
        CustomerOrders.PrintInvoice Me.Customer_ID, OrderID
       
        End If
    ElseIf ValidateOrder(Invoiced_CustomerOrder) Then
       
        ' Create Invoice Record
        If CustomerOrders.CreateInvoice(OrderID, 0, InvoiceID) Then
            
            ' Mark all Order Items Invoiced
            ' Need to change Inventory Status to SOLD from HOLD
            Dim rsw As New RecordsetWrapper
            With rsw.GetRecordsetClone(Me.sbfOrderDetails.Form.Recordset)
               While Not .EOF
                    If Not IsNull(![Inventory ID]) And ![Status ID] = OnHold_OrderItemStatus Then
                        rsw.Edit
                        ![Status ID] = Invoiced_OrderItemStatus
                        rsw.Update
                        Inventory.HoldToSold ![Inventory ID]
                    End If
                    rsw.MoveNext
               Wend
            End With
            
            ' Print the Invoice
          CustomerOrders.PrintInvoice Me.Customer_ID, OrderID

       
            SetFormState
        End If
    End If
End Sub



Private Sub cmdShipOrder_Click()
    If Not CustomerOrders.IsInvoiced(Nz(Me![Order ID], 0)) Then
        MsgBoxOKOnly CannotShipNotInvoiced
    ElseIf Not ValidateShipping() Then
        MsgBoxOKOnly ShippingNotComplete
    Else
        Me![Status ID] = Shipped_CustomerOrder
    
        If IsNull(Me![Shipped Date]) Then
            Me![Shipped Date] = Date
        End If
        eh.TryToSaveRecord
        SetFormState
    End If
End Sub


Private Sub Customer_ID_AfterUpdate()
    Me.sbfOrderDetails.Form.[Product ID].RowSource = "SELECT Inventory.[Product ID], Inventory.[Product Code], Inventory.[Qty Available] from Inventory where [Product Code] like '*" & Customer_ID & "*'"

    SetFormState False
    If Not IsNull(Me![Customer ID]) Then
        SetDefaultShippingAddress
    End If
End Sub
Private Sub Customer_ID_Current()
     If Not Me.NewRecord Then
       Me.sbfOrderDetails.Form.[Product ID].RowSource = "SELECT Inventory.[Product ID], Inventory.[Product Code], Inventory.[Qty Available] from Inventory where [Product Code] like '*" & Customer_ID & "*'"

     End If
End Sub



Private Sub Customer_ID_KeyUp(KeyCode As Integer, Shift As Integer)

    Me.Customer_ID.RowSource = "SELECT [ID], [Company], [Address For Ship], [ID] FROM [Customers Extended]where [Company], [Address For Ship], [ID] like '*" & Me.Customer_ID.Text & "*' order by [Company], [Address For Ship]"
    Me.Customer_ID.Dropdown
End Sub


Private Sub Form_Current()
    
    SetFormState
   
End Sub


Private Sub Form_Load()
    SetFormState
End Sub


Function GetDefaultSalesPersonID() As Long
    GetDefaultSalesPersonID = GetCurrentUserID()
End Function

Function ValidateShipping() As Boolean
   If Nz(Me![Shipping Fee]) = "" Then Exit Function
    ValidateShipping = True
End Function

Function ValidatePaymentInfo() As Boolean
    If IsNull(Me![Payment Type]) Then Exit Function
    If IsNull(Me![Paid Date]) Then Exit Function
    
    ValidatePaymentInfo = True
End Function


Sub SetFormState(Optional fChangeFocus As Boolean = True)
    If fChangeFocus Then Me.Customer_ID.SetFocus
    Dim Status As CustomerOrderStatusEnum
       
    Status = Nz(Me![Status ID], New_CustomerOrder)

    TabCtlOrderData.Enabled = Not IsNull(Me![Customer ID])
    Me.cmdCreateInvoice.Enabled = (Status = New_CustomerOrder)
    
    Me.cmdShipOrder.Enabled = (Status = New_CustomerOrder) Or (Status = Invoiced_CustomerOrder)
   
    Me.cmdDeleteOrder.Enabled = (Status = New_CustomerOrder) Or (Status = Invoiced_CustomerOrder)
    Me.cmdCompleteOrder.Enabled = (Status <> Closed_CustomerOrder)
    
    
    Me.[Order Details_Page].Enabled = (Status = New_CustomerOrder)
    Me.[Shipping Information_Page].Enabled = (Status = New_CustomerOrder)
    Me.[Payment Information_Page].Enabled = (Status <> Closed_CustomerOrder)
    
    Me.Customer_ID.Locked = (Status <> New_CustomerOrder)
    Me.Employee_ID.Locked = (Status <> New_CustomerOrder)
    Me.sbfOrderDetails.Locked = (Status <> New_CustomerOrder)

End Sub


Function ValidateOrder(Validation_OrderStatus As CustomerOrderStatusEnum) As Boolean
    If IsNull(Me![Customer ID]) Then
        MsgBoxOKOnly MustSpecifyCustomer
    ElseIf IsNull(Me![Employee ID]) Then
        MsgBoxOKOnly MustSpecifySalesPerson
    ElseIf Not ValidateShipping() Then
        MsgBoxOKOnly ShippingNotComplete
    Else
        If Validation_OrderStatus = Closed_CustomerOrder Then
            If Not ValidatePaymentInfo() Then
               MsgBoxOKOnly PaymentInfoNotComplete
               Exit Function
            End If
        End If

        Dim rsw As New RecordsetWrapper
        With rsw.GetRecordsetClone(Me.sbfOrderDetails.Form.Recordset)
            ' Check that we have at least one specified line items
            If .RecordCount = 0 Then
               MsgBoxOKOnly OrderDoesNotContainLineItems
            Else
               ' Check all that all line items have allocated inventory
               Dim LineItemCount As Integer
               Dim Status As OrderItemStatusEnum
               LineItemCount = 0
               While Not .EOF
                    
                    LineItemCount = LineItemCount + 1
                    Status = Nz(![Status ID], None_OrderItemStatus)
                    If Status <> OnHold_OrderItemStatus And Status <> Invoiced_OrderItemStatus Then
                        MsgBoxOKOnly MustBeAllocatedBeforeInvoicing
                        Exit Function
                    End If
                    rsw.MoveNext
               Wend
                                        
               ValidateOrder = True
            End If
        End With
    End If
End Function


ผลที่ได้คือเวลาพิมหาแล้วขึ้นกล่องว่าเปล่าค่ะ

91 Reply in this Topic. Dispaly 5 pages and you are on page number 5

81 @R14909
พอหนูsaveแล้วกดปุ่ม โปรแกรมขึ้นว่า ID is Required แล้วก็ไม่post ค่ะ
82 @R14910
เปลี่ยนโค้ดจาก
    If Me.Dirty Then
        MsgBox "Please save editing product first.", vbExclamation, Me.Caption
        GoTo Exit_Sub
    End If

ให้เป็นบรรทัดเดียว
    If Me.Dirty Then Me.Dirty = False
83 @R14911
อาจารย์คะ มันขึ้น ID is Required โปนแกรมต้องการ ID ของตัวไหนอะคะ
84 @R14912
อาจารย์คะ ทำได้แล้วค่ะขอบพระคุณมากๆค่ะอาจารย์


;)
85 @R14914
อาจารย์ค่ะ ไม่ได้อีกแล้ว :( พอหนูกลับไปดูโปรแกรมไม่ได้post จำนวนขึ้นไปอะค่ะ คือหนูadd สินค้า ราคา+save แต่พอกด add ก็ยังขึ้นว่า ต้องการ ID :(
86 @R14915
Update ค่ะ แก้ไขได้แล้วค่ะ ถ้าไม่ได้ยังอีกจะมาใหม่นะคะ ขอบพระคุณมากๆค่ะ
87 @R14957
อาจารย์คะ มาอีก1 เรื่อง ในcodeนี้อะค่ะถ้าเรากดปุ่มเปิด Invoice ไปแล้ว พอกลับมาเข้าดูฟอร์มใหม่บางทีมันผิดแต่ปริ้นไปแล้วมันแก้ไขอะไรไม่ได้ต้องไปแก้จากตาราง
หนูอยากแก้ไขจากฟอร์มเลยได้ไหมคะ ต้องแก้ code ตรงไหนคะ ในกรณีที่เราเปิดinvoice ไปเรียบร้อยแล้วอะค่ะ รบกวนอาจารย์อีกทีนะคะ

Form Order Detail

Option Compare Database
Option Explicit


Sub SetDefaultShippingAddress()
    If IsNull(Me![Customer ID]) Then
        ClearShippingAddress
    Else
       
        Dim rsw As New RecordsetWrapper
        If rsw.OpenRecordset("Customers Extended", "[ID] = " & Me.Customer_ID) Then
        Me.[InvoiceNO] = DMax("[InvoiceNumber]", "[Orders]") + 1
            With rsw.Recordset
               Me![Ship Name] = ![Contact Name]
               Me![Ship Address] = ![Address]
               End With
        End If
    End If
End Sub

Private Sub cmdDeleteOrder_Click()
     Dim DB      As DAO.Database
    Dim InTrans As Boolean
     
On Error GoTo Err_Handling

    InTrans = False
    Set DB = CurrentDb

    If IsNull(Me![Order ID]) Then
        Beep
    ElseIf MsgBoxYesNo(CancelOrderConfirmPrompt) Then
        InTrans = True: DBEngine.BeginTrans
             DB.Execute "delete * from [Inventory Transactions] where [Customer Order ID] = " & CStr(Me![Order ID])
             DB.Execute "delete * from [Orders] where [Order ID] = " & CStr(Me![Order ID])
             DB.Execute "delete * from [Order Details] where [Order ID] = " & CStr(Me![Order ID])
             DB.Execute "delete * from [Invoices] where [Order ID] = " & CStr(Me![Order ID])
        DBEngine.CommitTrans: InTrans = False
        MsgBoxOKOnly CancelOrderSuccess
        eh.TryToCloseObject
    End If

Exit_Sub:
    Set DB = Nothing
    Exit Sub
     
Err_Handling:
    If InTrans Then DBEngine.Rollback: InTrans = False
    MsgBox "Error code " & Err.Number & ", " & Err.Description
    MsgBoxOKOnly CancelOrderFailure
    Resume Exit_Sub
End Sub


Private Sub cmdClearAddress_Click()
    ClearShippingAddress
End Sub


Private Sub ClearShippingAddress()
    Me![Ship Name] = Null
    Me![Ship Address] = Null
    Me![Ship City] = Null
    Me![Ship State/Province] = Null
    Me![Ship ZIP/Postal Code] = Null
    Me![Ship Country/Region] = Null
End Sub


Private Sub cmdCompleteOrder_Click()
    If Me![Status ID] <> Shipped_CustomerOrder Then
        MsgBoxOKOnly OrderMustBeShippedToClose
    ElseIf ValidateOrder(Closed_CustomerOrder) Then
        Me![Status ID] = Closed_CustomerOrder
        eh.TryToSaveRecord
        MsgBoxOKOnly OrderMarkedClosed
        SetFormState
    
    End If
End Sub


Private Sub cmdCreateInvoice_Click()
    Dim OrderID As Long
    Dim InvoiceID As Long

    OrderID = Nz(Me![Order ID], 0)
    
    ' Gracefully exit if invoice already created
    If CustomerOrders.IsInvoiced(OrderID) Then
        If MsgBoxYesNo(OrderAlreadyInvoiced) Then
       
        CustomerOrders.PrintInvoice Me.Customer_ID, OrderID
       
        End If
    ElseIf ValidateOrder(Invoiced_CustomerOrder) Then
       
        ' Create Invoice Record
        If CustomerOrders.CreateInvoice(OrderID, 0, InvoiceID) Then
            
              
            ' Mark all Order Items Invoiced
            ' Need to change Inventory Status to SOLD from HOLD
            Dim rsw As New RecordsetWrapper
            With rsw.GetRecordsetClone(Me.sbfOrderDetails.Form.Recordset)
               While Not .EOF
                    If Not IsNull(![Inventory ID]) And ![Status ID] = OnHold_OrderItemStatus Then
                        rsw.Edit
                        ![Status ID] = Invoiced_OrderItemStatus
                        rsw.Update
                        Inventory.HoldToSold ![Inventory ID]
                    End If
                    rsw.MoveNext
               Wend
            End With
            
            ' Print the Invoice
          CustomerOrders.PrintInvoice Me.Customer_ID, OrderID

       
            SetFormState
        End If
    End If
End Sub
Private Sub preview_Click()
    Dim OrderID As Long
    Dim InvoiceID As Long

    OrderID = Nz(Me![Order ID], 0)
    
    ' Gracefully exit if invoice already created
    If CustomerOrders.IsInvoiced(OrderID) Then
        If MsgBoxYesNo(OrderAlreadyInvoiced) Then
       
        CustomerOrders.PrintInvoice1 Me.Customer_ID, OrderID
       
        End If
    ElseIf ValidateOrder(Invoiced_CustomerOrder) Then
       
        ' Create Invoice Record
        If CustomerOrders.CreateInvoice(OrderID, 0, InvoiceID) Then
            
            ' Mark all Order Items Invoiced
            ' Need to change Inventory Status to SOLD from HOLD
            Dim rsw As New RecordsetWrapper
            With rsw.GetRecordsetClone(Me.sbfOrderDetails.Form.Recordset)
               While Not .EOF
                    If Not IsNull(![Inventory ID]) And ![Status ID] = OnHold_OrderItemStatus Then
                        rsw.Edit
                        ![Status ID] = Invoiced_OrderItemStatus
                        rsw.Update
                        Inventory.HoldToSold ![Inventory ID]
                    End If
                    rsw.MoveNext
               Wend
            End With
            
            ' Print the Invoice
          CustomerOrders.PrintInvoice1 Me.Customer_ID, OrderID

       
            SetFormState
        End If
    End If
End Sub


Private Sub cmdShipOrder_Click()
    If Not CustomerOrders.IsInvoiced(Nz(Me![Order ID], 0)) Then
        MsgBoxOKOnly CannotShipNotInvoiced
    ElseIf Not ValidateShipping() Then
        MsgBoxOKOnly ShippingNotComplete
    Else
        Me![Status ID] = Shipped_CustomerOrder
    
        If IsNull(Me![Shipped Date]) Then
            Me![Shipped Date] = Date
        End If
        eh.TryToSaveRecord
        SetFormState
    End If
End Sub


Private Sub Customer_ID_AfterUpdate()
    Me.sbfOrderDetails.Form.[Product ID].RowSource = "SELECT Inventory.[Product ID], Inventory.[Product Code], Inventory.[Qty Available], Inventory.[disc] from Inventory where [Product Code] like '" & Customer_ID & " *'"

    SetFormState False
    If Not IsNull(Me![Customer ID]) Then
        SetDefaultShippingAddress
    End If
End Sub
Private Sub Customer_ID_Current()
     If Not Me.NewRecord Then
       Me.sbfOrderDetails.Form.[Product ID].RowSource = "SELECT Inventory.[Product ID], Inventory.[Product Code], Inventory.[Qty Available], Inventory.[disc] from Inventory where [Product Code] like '*" & Customer_ID & "*'"

     End If
End Sub


Private Sub Customer_ID_KeyUp(KeyCode As Integer, Shift As Integer)
    Me.Customer_ID.RowSource = "SELECT [ID], [Company], [Address For Ship], [ID] , [MemberName], [Code] FROM [Customers Extended] where ([Company] like '*" & Me.Customer_ID.Text & "*') or ([Address For Ship] like '*" & Me.Customer_ID.Text & "*') or ([ID] like '*" & Me.Customer_ID.Text & "*') or ([MemberName] like '*" & Me.Customer_ID.Text & "*') or ([ADDRESS2] like '*" & Me.Customer_ID.Text & "*') or ([ADDRESS3] like '*" & Me.Customer_ID.Text & "*') or ([ADDRESS4] like '*" & Me.Customer_ID.Text & "*') or ([ship2] like '*" & Me.Customer_ID.Text & "*') or ([ship3] like '*" & Me.Customer_ID.Text & "*') or ([ship4] like '*" & Me.Customer_ID.Text & "*') or ([Code] like '*" & Me.Customer_ID.Text & "*') order by [Company], [Address For Ship]"
    Me.Customer_ID.Dropdown
End Sub



Private Sub Form_Current()
    
    SetFormState
   
End Sub


Private Sub Form_Load()
    SetFormState
End Sub


Function GetDefaultSalesPersonID() As Long
    GetDefaultSalesPersonID = GetCurrentUserID()
End Function

Function ValidateShipping() As Boolean
   If Nz(Me![Shipping Fee]) = "" Then Exit Function
    ValidateShipping = True
End Function

Function ValidatePaymentInfo() As Boolean
    If IsNull(Me![Payment Type]) Then Exit Function
    If IsNull(Me![Paid Date]) Then Exit Function
    
    ValidatePaymentInfo = True
End Function


Sub SetFormState(Optional fChangeFocus As Boolean = True)
    If fChangeFocus Then Me.Customer_ID.SetFocus
    Dim Status As CustomerOrderStatusEnum
       
    Status = Nz(Me![Status ID], New_CustomerOrder)

    TabCtlOrderData.Enabled = Not IsNull(Me![Customer ID])
    Me.cmdCreateInvoice.Enabled = (Status = New_CustomerOrder)
    
    Me.cmdShipOrder.Enabled = (Status = New_CustomerOrder) Or (Status = Invoiced_CustomerOrder)
   
    Me.cmdDeleteOrder.Enabled = (Status = New_CustomerOrder) Or (Status = Invoiced_CustomerOrder)
    Me.cmdCompleteOrder.Enabled = (Status <> Closed_CustomerOrder)
    
    
    Me.[Order Details_Page].Enabled = (Status = New_CustomerOrder)
    Me.[Shipping Information_Page].Enabled = (Status = New_CustomerOrder)
    Me.[Payment Information_Page].Enabled = (Status <> Closed_CustomerOrder)
    
    Me.Customer_ID.Locked = (Status <> New_CustomerOrder)
    Me.Employee_ID.Locked = (Status <> New_CustomerOrder)
    Me.sbfOrderDetails.Locked = (Status <> New_CustomerOrder)

End Sub


Function ValidateOrder(Validation_OrderStatus As CustomerOrderStatusEnum) As Boolean
    If IsNull(Me![Customer ID]) Then
        MsgBoxOKOnly MustSpecifyCustomer
    ElseIf IsNull(Me![Employee ID]) Then
        MsgBoxOKOnly MustSpecifySalesPerson
    ElseIf Not ValidateShipping() Then
        MsgBoxOKOnly ShippingNotComplete
    Else
        If Validation_OrderStatus = Closed_CustomerOrder Then
            If Not ValidatePaymentInfo() Then
               MsgBoxOKOnly PaymentInfoNotComplete
               Exit Function
            End If
        End If

        Dim rsw As New RecordsetWrapper
        With rsw.GetRecordsetClone(Me.sbfOrderDetails.Form.Recordset)
            ' Check that we have at least one specified line items
            If .RecordCount = 0 Then
               MsgBoxOKOnly OrderDoesNotContainLineItems
            Else
               ' Check all that all line items have allocated inventory
               Dim LineItemCount As Integer
               Dim Status As OrderItemStatusEnum
               LineItemCount = 0
               While Not .EOF
                    
                    LineItemCount = LineItemCount + 1
                    Status = Nz(![Status ID], None_OrderItemStatus)
                    If Status <> OnHold_OrderItemStatus And Status <> Invoiced_OrderItemStatus Then
                        MsgBoxOKOnly MustBeAllocatedBeforeInvoicing
                        Exit Function
                    End If
                    rsw.MoveNext
               Wend
                                        
               ValidateOrder = True
            End If
        End With
    End If
End Function



อันนี้ form order detail subform
Option Compare Database
Option Explicit




Private Sub Product_ID_AfterUpdate()

    'Initialize price and discount for each product change
     
    If Not IsNull(Me![Product ID]) Then
        Me![Quantity] = 0
        Me.Quantity.Locked = False
        Me![Unit Price] = GetListPrice(Me![Product ID])
        Me![Discount] = 0
        Me![Status ID] = None_OrderItemStatus
        Me.Discount = Nz(Me.Product_ID.Column(3), 0)

    'Empty Product records mean user wants to delete line item
    Else
        eh.TryToRunCommand acCmdDeleteRecord
    End If
End Sub


Private Sub Form_Current()
    If Nz(Me![Status ID], None_OrderItemStatus) = Invoiced_OrderItemStatus Then
        Me.AllowEdits = False
    Else
        Me.AllowEdits = True
    End If
End Sub


Private Sub Quantity_AfterUpdate()
    On Error GoTo ErrorHandler
    
    Dim IT As InventoryTransaction
    Dim PurchaseOrderID As Long
    Dim SupplierID As Long
    
    IT.ProductID = Nz(Me![Product ID], 0)
    IT.Quantity = Me![Quantity]
    IT.AllOrNothing = True
    IT.InventoryID = Nz(Me![Inventory ID], NewInventoryID)
    
    'Request Hold on specified Inventory
    If Inventory.RequestHold(Me![Order ID], IT) Then
        Me![Inventory ID] = IT.InventoryID
        Me![Status ID] = OnHold_OrderItemStatus
       
    'Insufficient Inventory
    ElseIf Me![Status ID] <> None_OrderItemStatus And Me![Status ID] <> NoStock_OrderItemStatus Then
        MsgBoxOKOnly InsufficientInventory
        Me![Quantity] = Me.Quantity.OldValue
    
    'Attempt to create purchase order for back ordered items
    ElseIf MsgBoxYesNo(NoInventoryCreatePO) Then
     
        SupplierID = Inventory.FindProductSupplier(IT.ProductID)
       
        'Create purchase order if we have supplier for this product
        If SupplierID > 0 Then
            If PurchaseOrders.Generate(SupplierID, IT.ProductID, Me![Quantity], Me![Order ID], PurchaseOrderID) Then
               PurchaseOrders.OpenOrder PurchaseOrderID
               Me![Status ID] = OnOrder_OrderItemStatus
               Me![Purchase Order ID] = PurchaseOrderID
               eh.TryToSaveRecord
            Else
               Me![Status ID] = NoStock_OrderItemStatus
            End If
            
        'Could not find a supplier for this product
        Else
            MsgBoxOKOnly CannotCreatePO_NoSupplier
            Me![Status ID] = NoStock_OrderItemStatus
        End If
       
    Else
        Me![Status ID] = NoStock_OrderItemStatus
    End If
    
Done:
    Exit Sub

ErrorHandler:
    ' Resume statement will be hit when debugging
    If eh.LogError("Quantity_AfterUpdate") Then Resume
End Sub


Private Sub Status_Name_DblClick(Cancel As Integer)
    Select Case Me![Status ID]
    Case NoStock_OrderItemStatus, None_OrderItemStatus
        Quantity_AfterUpdate
    Case OnOrder_OrderItemStatus
        Dim PurchaseOrderID As Long
        PurchaseOrderID = Nz(Me![Purchase Order ID], 0)
        If PurchaseOrderID > 0 Then
            PurchaseOrders.OpenOrder PurchaseOrderID
            Me.Requery
        End If
    Case Invoiced_OrderItemStatus
    End Select
End Sub


ขอบพระคุณค่ะ

88 @R14958
ระบบมีการล็อคเอาไว้เพื่อไม่ให้เปิดบิลแล้วกลับมาแก้ order เดิมได้ ดังนั้นขั้นตอนของ business operation ทุกขั้นตอนที่โปรแกรมได้วางไว้ต่อจากนี้ และความถูกต้องของข้อมูลต่อจากนี้ มันยืนอยู่บนพื้นฐานที่มั่นใจว่า order จะไม่ถูกแก้ไขได้อีก และบิลก็จะไม่ถูกเปลี่ยนแปลงด้วย ดังนั้นถ้าจะแก้ไขตรงนี้ จะต้องไปดูทั้งระบบเลยครับว่ากระทบอย่างไรบ้าง ซึ่งไม่ใช่เรื่องเล็กๆแล้ว และไม่ควรที่จะทำ ควรที่จะทำตามขั้นตอนที่โปรแกรมมีให้ไว้ เช่น ยกเลิก order เดิม (ไม่ทราบว่าทำได้หรือไม่) แล้วป้อนใหม่เป็นอีกใบอีกหมายเลข ซึ่งกรณีนี้ต่างจากในกรณีของคำถามเก่าที่ให้เปิด PO พร้อมโพสลง Inventory ได้ ตรงนั้นเราพอจะทำได้เพราะนั่นเป็นการทำตาม business operation ที่เดินไปข้างหน้า เพียงแต่เราลัดขั้นตอนการปฏิบัติงาน และมีการแก้ไขไม่มากเท่านั้นครับ
89 @R14959
ตามนะค่ะ ท่านอาจารย์ :)
90 @R14962
ตาม อะไรครับ ? งานนี้ผมไม่แก้ให้นะครับ เพราะผมไม่แน่ใจว่าจะเกิดผลกระทบต่อไปยังไงบ้าง เกิดแก้ไปแล้วมีปัญหา กลายเป็นว่าผมต้องมานั่งรับผิดชอบระบบนี้แทน ซึ่งเกินภาระที่ผมจะรับได้ครับ
91 @R14969
ขอโทษค่ะ อาจารย์ หนูตั้งใจจะเขียนว่า ตามนั้นค่ะอาจารย์ คือหนู ไม่ทำแบบที่แก้ไขได้แล้วค่ะ คือ พอหนูเอาโปรแกรมมาใช้ กับ head office คนที่ทำค่อนข้างไม่เข้าใจเกี่ยวกับ เทคโนโลยีมากนัก แล้วพอเค้าเปิดผิดเค้าก็แก้ไม่เป็น มันทำให้งานช้าอะค่ะ หนูเลยคิดว่า จะให้แก้ไขตรงนั้นได้ พอมาถามอาจารย์ อาจารย์บอกว่ามันจะมี ปัญหามากระทบหลายอย่าง หนูเลย พิมพ์บอกอาจารย์ ตามนั้น คือตามที่อาจารย์บอกนะคะ ขอโทษด้วยค่ะ
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.2111s