Need item selected from drop down to compare a quantity of that item and update table - vba

So I've been building an MS Access database for our business to track repair tickets and other info. I'm almost finished with it, but want to add a function based on a selection of a drop down.
I have a table with items listed that we use for repairs, along with an on-hand quantity. Within the repair ticket form, I want to be able to select an item from a drop down, compare the on-hand quantity of that item within the table, which will then determine the next steps. Essentially, if there is an on-hand > 0, then the status of the ticket changes, as well as update the quantity of of the table (like if on-hand = 25, selecting that item automatically removes 1 from the quantity, making it 24, etc.). In addition, if the repair isn't approved, it should obviously add 1 to the quantity since that item wasn't used for that repair.
There is already a drop down that populates the item to the repairticket table, and want to use the same drop down for the added function, if that makes any sense.
I can write the code for status changes and whatnot, but don't know how to make it compare the quantities and update the separate Item List table.
Any help and guidance would be much appreciated!! And thanks in advance!!
-Andrew

Related

Does transaction locks the row to prevent the data inconsistancy

I am new to MSSQL and creating a website where Customers can place orders.
Each order may have multiple items with any number of quantity.
I am interested in before saving my order to check if the desired quantity is available for each item, if yes then I will place the order and update the items inventory, otherwise I want to rollback.
But at the same time I want that any other order should wait till first transaction is finished. So that up updates don't overwrite the changes and produce inconsistency.
If each order is processed within a transaction, is it enough or do I have to consider something else too?
If you go on any Online retail website, you will notice that you go through the shop, buying stuff (not actually buying but being added to a basket) and once you have completed your shopping you go to Checkout that is, where you are asked to provide payment details etc.
So the idea is, the website shows everything (that has at least 1 stock item) to every customer, At this point no item inventory is being updated or inserted, at the checkout stage a complete order is compiled and submitted to system, (at this stage you will do the actual updates/inserts to item stock inventory) now how you want to handle the orders is entirely up to you.
Do you want to rollback entire order when any one item has less stock than
the quantity ordered?
Do you want to commit all order lines and only rollback those order lines where the items has less stock than quantity ordered?
Or do you want to place a provisional
order regardless of the stock availability and manipulate the delivery date?
Depending on what path you chose to go with (this should be a business decision a developer shouldn't be making these decisions) there is a lot of flexibility, but one thing you never do is as soon as someone has select to buy an item, you update the inventory. All this should be done right in the end of the Purchase process and all should be done at Once.

Sql Transaction for POS

I am developing a POS for a pharmacy the scenario is like this:
1. a user select category and then Item, then the item will be pass to DataGridview, the use can increase and decrease the value of item.
2. the user select customer and other necessary information.
3. the user press the pay button and all insertion to stock, account register, sales invoice will be done in back of this pay button.
P.S: this system is multi User, mean Lan based.
Now, my question is that, I am trying to tell that system that check with still no changes come to qty of item in stock, if come rollback else commit.
Can I use Sql Transaction or no?
Thanks in Advance for answer.

MS Access manual Auto incrementing field

Im building a system for my company to keep track of internal orders, inbetween our warehouses, we have material that goes out warehouse 1 to warehouse 2 and we kind of lose track of how much of "x" is in warehouse 1 and how much in warehouse 2, so i want to implement this access db where a user fills a form and says: order 1: 500 of "x" order 2: 300 of "y". then another user fills an exit form where he says 1 of "x" going out, so i would need the program to keep track of total order and how much as gone out to fill order 1 and so on...
My idea here is to have both an order number and an id number for each of "x" everytime someoneone assembles 1 "x" they fill the form and print a label directly from the access (i have this part working already) while keeping a record of when it was assembled, who verified and what was verified (it will work as a quality control also).
What i dont know is how to program the db so when it reaches 500 of "x", the id number for "x" starts again from 1
This is the one major issue with my program right now, i'm not experienced in access db's or vba, but im getting there with a tip and a trick from here and there, so, no need to be careful with the technical language, i will google it if i have to :p
EDIT:
The table structure goes as follows:
1 table as the main table where I record the check that is made for every product, where I include the model of the product, the said ID that I want to reset after a number of products checked, and a concatenated field that includes most of this information to generate a qr code.
Then there is a table for the Order Number, which is connected to a form to record each new order with a date/time field, the order number itself and the number of products. This number of products must then be called from the code that will count how many products have been checked to date and keep the order number field updated so we can keep track of the order.
Then there is another minor table just to get values for the form, the product models
Thank you for your answers ;)
See this MSDN Documentation
Unfortunately in Access, you cannot 'reset' an ID field, unless you move the records to a newly created table and use that table for every 500 records.
As for the user control and login form, I'm afraid those are separate questions that must be asked in a different thread.
To get you started:
You can set the RecordSource of a form to a table, and when users make entries, the data will be saved to the table. You can also use a form with controls (text boxes, comboboxes, etc.) and create a button that runs a query to insert these records into a table.
The login piece - you can encrypt the database with a password. That may/may not be sufficient.
I would suggest you change your schema, if possible. Something like the following:
Orders
OrderID (Autonumber)
ProductID (link to your Products table)
QuantityRequested
Deliverables
DeliverableID (Autonumber)
OrderID (link to your Orders table)
SequenceNumber: in the BeforeInsert event set this value equal to:
DCount("*", "Deliverables", "OrderID=" & Me.OrderID) + 1
I'm assuming that your form has a control named OrderID that is bound to the OrderID field of the Deliverables table.
The code uses the DCount() function to get the count of all the other deliverables that have already been created for this order. If this is the first deliverable, DCount() will return 0. It then adds 1 to this count to get the sequence number of the next deliverable.
If the new SequenceNumber is greater than the quantity requested, you could display a message saying that the order has been filled and cancel the creation of the Deliverable record.
This is just one approach and it is not a complete solution. I'm assuming that once assigned a sequence number a deliverable cannot be deleted. You might need to make allowances for deliverables that get lost or damaged. You could incorporate a status field to the Deliverable table to deal with this, but you would still need to make a decision about what to do with the SequenceNumber.

How to update stock quantity

VB.NET
Well, I'm using Access as DB containing five tables viz. Vendors, PurOrder, Customers, SalesOrder, Stock.
Vendors: VendorID(PK), Name, Contact, Phone, Address.
PurOrder: POID(PK), Items, Quantity, Rate, Total
Customers: CustID(PK), Name, Phone, Address
SalesOrder: SOID(PK), Items, Quantity, Rate, Total
Stock: SItemID(PK), Items, Quantity, Rate, Total
I'm using the Database Wizard in VB.NET Express. I do not need to code for that. I click on Data Sourses > add the Database > Drag that to my Purchase and Sales form and that automaticaly creates the ADD, DELETE, & SAVE as well as Navigation buttons as toolstrip. and furthermore I drag the Purchase order table (for example) to the form in Datagrid mode and that's it! Now, I can SAVE, DELETE, & ADD records to my database as Purchases.
Well I am able to enter and save/update purchase and sales vouchers and retrieve the reports Customer/Vendor ID-wise and print that.
The only problem I have is that I don't know what to do in order to automatically update the sock quantity when purchase or sale is made.
Thanks in advance.
In many other mainstream database software, they support Trigger, which achieves your goal (automatic update the purchase count). Consider using other database software, as MS Access's performance is not so good.
To answer your question, you have to do an extra query to update the value.

Database Design: Line Items & Additional Items

I am looking for a solution or to be told it simply is not possible/good practice.
I currently have a database whereby I can create new orders and select from a lookup table of products that I offer. This works great for the most part but i would also like to be able to add random miscellaneous items to the order. For instance one invoice may read "End of Tenancy Clean" and the listed product but then have also an entry for "2x Lightbulb" or something to that effect.
I have tried creating another lookup table for these items but the problem is i don't want to have to pre-define every conceivable item before I can make orders. I would much prefer to be able to simply type in the Item and price when it is needed.
Is there any database design or workaround that can achieve this? Any help is greatly appreciated. FYI I am using Lightswitch 2012 if that helps.
One option I've seen in the past is a record in your normal items table labeled something like "Additional Service", and the application code will recognize this item and also require you to enter or edit a description to print with the invoice.
In the ERP system which we have at work, there is a flag in the parts table which allows one to change the description of the part in orders; in other words, one lists the part number in the order and then changes the description. This one off description is stored in a special table (called NONSTANDARD) which basically has two fields - an id field and the description. There is a field in the 'orderlines' table which stores the id of the record in the special table. Normally the value of this field will be 0, which means that the normal description of the part be displayed, but if it's greater than 0, then the description is taken from the appropriate row in the nonstandard table.
You mean something like this?
(only key attributes included, for brevity)