nortwind (1 Viewer)

PWG

Registered User.
Local time
Yesterday, 22:22
Joined
Jun 13, 2019
Messages
56
Im using northwind to create a inventory database.
I have found that when i receive in goods it dose not change the purchase order status to closed. Looking at the code I can see that I have met all the criteria but it does not change the status to closed.
I can upload what I have but it does not work on the standard microsoft template ether.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:22
Joined
Oct 29, 2018
Messages
21,471
Hi. Any additional information might be helpful. Not too many people are familiar with every aspect of Northwind (me included).
 

GinaWhipp

AWF VIP
Local time
Today, 01:22
Joined
Jun 21, 2011
Messages
5,899
Hmm, would help if you post the code you reviewed.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:22
Joined
Feb 19, 2002
Messages
43,266
Northwind is not actually a fully functional application. So, if something isn't working, it probably wasn't coded. There are also multiple versions of Northwind so you would need to post the version you are using since looking at a version we have wouldn't help us at all.
 

PWG

Registered User.
Local time
Yesterday, 22:22
Joined
Jun 13, 2019
Messages
56
Thanks for that I did not know it was not fully functional that would explain so of the other problems I have over come.
I don0t realy understand code so have copied a lot from Northwind maybe not a good idea then
 

GinaWhipp

AWF VIP
Local time
Today, 01:22
Joined
Jun 21, 2011
Messages
5,899
Well, if you post what you have we could see why it's not giving you the desired results.
 

PWG

Registered User.
Local time
Yesterday, 22:22
Joined
Jun 13, 2019
Messages
56
This is the code that I think should change the status to closed

Public Sub InitFormState()
Dim Status As PurchaseOrderStatusEnum

Me.Supplier_ID.SetFocus

Status = Nz(Me![Status ID], New_PurchaseOrder)

Me.cmdSubmitforApproval.Enabled = (Status = New_PurchaseOrder)
Me.cmdApprovePurchase.Enabled = (Status = Submitted_PurchaseOrder)
Me.cmdCancelPurchase.Enabled = (Status <> New_PurchaseOrder)

If IsNull(Me![Supplier ID]) Then
Me.[Purchase Details_Page].Enabled = False
Else
Me.[Purchase Details_Page].Enabled = (Status = New_PurchaseOrder) Or (Status = Submitted_PurchaseOrder)
End If

Me.[Inventory Receiving_Page].Enabled = (Status = Approved_PurchaseOrder)
Me.[Payment Information_Page].Enabled = (Status = Approved_PurchaseOrder)

Me.AllowEdits = Not (Status = Closed_PurchaseOrder)
Me.AllowDeletions = Not (Status = Closed_PurchaseOrder)
End Sub
 

PWG

Registered User.
Local time
Yesterday, 22:22
Joined
Jun 13, 2019
Messages
56
This is the code on the tick box

Private Sub Posted_To_Inventory_AfterUpdate()
On Error GoTo ErrorHandler

Dim InventoryID As Long
Dim ProductID As Long
Dim Quantity As Long

ProductID = Nz(Me![Product ID], 0)
Quantity = Nz(Me![Quantity], 0)
InventoryID = Nz(Me![Inventory ID], 0)

'Posting New Inventory
If Me![Posted To Inventory] Then
If IsNull(Me![Date Received]) Then
Me![Date Received] = Date
End If

If Inventory.AddPurchase(Me![Purchase Order ID], ProductID, Quantity, InventoryID) Then
If InventoryID > 0 Then
Me![Inventory ID] = InventoryID
Me![Posted To Inventory] = True
MsgBoxOKOnly InventoryPostingSuccess
End If
Else
Me![Posted To Inventory] = False
MsgBoxOKOnly InventoryPostingFailure
End If

eh.TryToSaveRecord

If Inventory.GetQtyOnBackOrder(ProductID) > 0 Then
If MsgBoxYesNo(FillBackOrdersPrompt) Then
Inventory.FillBackOrders ProductID
End If
End If

'Removing Posted Inventory
Else
If InventoryID > 0 Then
Me![Posted To Inventory] = True
End If
End If

Done:
Exit Sub

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


Private Sub Date_Received_AfterUpdate()
If Me![Posted To Inventory] Then
Debug.Assert False
ElseIf MsgBoxYesNo(PostReceivedProductPrompt) Then
Me![Posted To Inventory] = True
Posted_To_Inventory_AfterUpdate
End If
End Sub


Private Sub Form_Current()
Me.AllowEdits = Not Me![Posted To Inventory]
End Sub


Private Sub Form_Load()
Dim rsw As New RecordsetWrapper
With rsw.GetRecordsetClone(Me.Recordset)
'Ensure integrity of Inventory postings
While Not .EOF
If Not IsNull(![Inventory ID]) Then
rsw.Edit
![Posted To Inventory] = True
rsw.Update
End If
rsw.MoveNext
Wend
End With
End Sub
 

Users who are viewing this thread

Top Bottom