Need Help with Stock Transfer Form – Warehouse Issue

shobhanauto

New member
Local time
Today, 10:59
Joined
Dec 17, 2023
Messages
18
Hi everyone, how are you all?

I’ve created a form for stock transfer between warehouses, but it’s not working. Can anyone help me?

Details:

  • Total Warehouses: 4
    • W-ADMIN
    • W-MAIN
    • W-RETAILS
    • W-LOCALS
The form is supposed to transfer stock from one warehouse to another, but it’s not functioning. Any guidance would be appreciated!
 

Attachments

I am on my phone now, but if your structure is correct, all you should need to do is change the FK for the stock PK in the WarehouseStock junction table.
 
Not working is not very helpful. What is going wrong, specifically? Are you getting an error message (what?) or is one or more of the fields not getting the correct value?

To begin with I don't see a column named "Item Name" in your table and that is what the update query is using to locate the row to update.
Other issues:
1. your code should verify that the record the user is asking to update exists before running the update query.

Beyond that,
1. You need to backup and rethink your table schema. You shouldn't be using this method to update inventory at all. Plus, hard coding warehouses into specific columns is just plain wrong. There is no beating around the bush with this one. Don't do it. If you have to add a new warehouse. You have to modify any forms/reports/queries/code that work with warehouse which is an unnecessary maintenance burden. A warehouse name is a piece of data. Pieces of data are NEVER column names. If you wanted to store the state for a customer record, would you add 50 columns? One for each state? What you have done is to make that exact mistake.

2. You have merged three important functions into a single table.
a. Product list
b. Quantity on hand
c. Inventory movement
You should have at least two tables. One to store the product information and a second to store inventory transactions. To calculate quantity on hand, you sum the inventory transactions for the item/warehouse combination. Take a look at the Northwinds dev sample to see how inventory is properly kept and managed. You will make yourself crazy the way you are doing it because there is no auditibility. By using a transaction table, you get to see ALL movements of inventory, who made them and when so if your cycle count is wrong, you may be able to identify when it happened.

Now, your transfer of stock code needs to create two records. One to subtract the inventory from the from warehouse and a second to add the inventory to the to warehouse. Transfers are aways two record sets. From-To.

3. Using embedded spaces and special characters just makes everything harder to read in the code because all the non-conforming object names MUST be encased in square brackets [] which are jarring to the eye and add two characters to the length of every object name. When you use the object your eyes will play tricks on you and you will see () as [] and vice versa causing coding errors.

There are other issues but start with thinking about these 3.
 
<clip>

There are other issues but start with thinking about these 3.
A few more that immediately caught my eye:
1. Dnt abbrev obj nms - Don't abbreviate object names. You are creating this not just for yourself, but also for your successor after you win the lottery. Even your Descriptions in table design are often abbreviated. Also, a description of "STINNR1" for a field named "STINNR1" does not add any value. Also, you have no required fields other than PK. A blank record never makes much sense. Several blank records never make any sense.
2. ItemName is not an appropriate table name.
3. As Pat already said, this table does WAY too much work. It may have started in Excel perhaps? Anyway, this is not how you create a relational database. Stop development now, and read up on relational database design and the rules of normalization. Study some good templates, such as the Northwind Starter and Developer databases.
It would be interesting to contemplate how we would add multiple warehouses to Northwind. I'll kick that around with my team member Kim. Also note there is a YouTube video about how we implemented inventory in NW2-Dev.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom