Results 1 to 10 of 10
  1. #1
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125

    Performing calculations in a form

    Greetings to all;

    I am creating a DB among which there is a form named "FrmStock" with fields (SuppierID, PurchaseInvoiceNo, DateOfEntry,SecurityID, PurchaseID)
    This form has a SubForm "FrmStock2Subform" in DataSheet View containing fields (ProductName, Unit, UnitCost, PurchaseID)
    The SubForm is linked to the main form by PurchaseID

    I HAVE TWO PROBLEMS FOR NOW:
    1) I will like to have the total for each Product in the subForm as I enter the productName, Unit, UnitCost and Qty
    2) I will like to have a control that displays the Gross amount i.e the Grand Total

    Here attached is part of my DB

    BUSINess.zip

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    The form frmStock doesn't function at all. When I put a supplier there's nothing to aid me as the purchaseID is completely blank.

    Additionally you have some real problems with this database that are going to cause you problems and/or make your data entry more prone to errors in data entry but they don't relate directly to your question.

    If you are attempting to subtotal items in your subform you are not going to be successful. Let's say you have the same customer order a carton of an item, but then also order 15 individual items (assuming the quantities are different and a carton is, say, 36 of the item) You want your subtotal to be 41 items not 1 carton of product X and 15 of product X.

    To be able to do individual counts you'd need a support table that has the various product distributions (how many items per carton, how many cartons per pallet, etc)
    Additionally you should not be using user entered purchaseID's. Any field that relates two tables should not be user entered. You'd be better off making the PurchaseID an autonumber (similar to at least one of your other tables) and ALSO providing the ability for the user to enter an internal purchase order number. This way if someone mistypes PO-10001 and you want to correct it to PO-10010 you can do so without making orphans of a whole bunch of your data.

    These are the two biggest things preventing you from doing what you want but your form doesn't work at all right now and generates errors when I try to poke around with it. If you can get it working or tell me what you're doing in terms of data entry that gets a 'right' result (just not with the subtotaling you're talking about) I can have another look.

  3. #3
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125

    Thanks alot rpeare

    Actually I have written a VBA and attached to the Before update event of the form "frmstock" this permits to enter the purchaseID automatically. The problem with this situation is that I need to select the supplier's name first before I start entering the items in the subform. The reason is this: Suppose I enter the products first, by the time I want to select the supplier, the item will get themselves updated to the tblstock2 without me pressing the SAVE button. And if I make PurchaseID a required field in the table tblstock2, I will continuously receive an error msg telling me PurchaseID is required. Here am abit confused. What I need here is that the tableS should not be updated until I press the SAVE button.Concerning your proposal on the pricing conditions, I previewed sth like that so I created two tables which are in the DB you downloaded. "tblprice" and "tblprice2". These prices should be used when selling. I have tried to integrate this price in the form "frmsales" so that the user will enter PriductName, Unit,Quantity and optionally the OUP (optional UnitPrice). But it's not working yet. To do these, I created a quary "DATA" but the query is not updatable. I will be waiting on your sugestions

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    What are you trying to do (please be as clear as possible) with the following tables:

    tblprice
    tblprice2
    tblsales
    tblsales2
    tblstock
    tblstock2

    I suspect you are making this harder than it needs to be and I would like to know what you WANT to do with these.

  5. #5
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125
    Let me start with TblPrice and TblPrice2
    The issue is that
    1. Each product can have different units (e.g carton, Ream, sheet : this is for A4 papers)
    2. Each unit has a different price
    3. TblPrice stores the productName (e.g. Papers A4 ) and TblPrice2 Stores the prices of each unit of this product . (e.g. Carton-14ooo CFAF, Ream 2500 CFAF, Sheet-25 CFAF)

    Concerning TblSales and TblSales2
    1. TblSales is made to store the main items of an invoice such as InvoiceNo, CustomerName DateOfOrder
    2. TblSales 2 is made to store the details of different products sold including ProductName, Qty,
    3. These tables are linked by InvoiceNo.

    Concerning TblStock and TblStock2
    These tables are made to store the new stock that has just been supplied to replenish the stock. It could be a brand new product or an old product that the organization has been selling.
    1. TblStock stores the main information of the purchase invoice such as SupplierName, DateOfPurchase, UserID
    2. While TblStock2 stores the details of the products purchased. Such as Productname, Qty, Unit, UnitPrice

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Alright.

    First, your price and price2 are doing what I suggested in terms of structuring. However, I would suggest that your PRICEID field not be user entered. That can lead to too many problems. All fields that link tables should not be subject to human intervention. If you want an ID that is a visual reminder you can let them type something in but hide the actual linking field from them. In your case have a PRICEID field that's an autonumber in your tblPRICE table but still allow them to enter the AAA1, AAAAA etc. And you still need a junction table that, or alternately an additional field in your tblPRICE2 that tells how many units are in the larger item. For instance you currently have two entries for PRICEID AAAAA and AAAAB but there's no indication how many sticks are in a carton on of item AAAAA, nor is there an indication of how many packet are in a pack.

    So let's say you have iphones
    You will sell an individual Iphone for 400$
    You will sell a case of 10 iphones for 3000$
    You will sell a pallet of iphones for 25000$

    There are 10 phones per case
    there are 10 cases per pallet

    So your table would look more like:

    Code:
    tblUnit
    UnitID  UnitName
    1       Pack
    2       Case
    3       Pallet
    
    tblPrice2
    EntryID  Unit  UP       PriceID  Qty  SecurityID  DOE
    1        1     500      1        1
    2        2     300      1        10
    3        3     250      1        100
    So if you were to sell a pallet of iphones and you stored the quantity of individual items per pallet in your tblPrice2 you would be able to correctly add and subtract items from your inventory accurately. The way you currently have it set up you can not unless you are never breaking a pack to get an individual item.

    The only other thing I would be curious about is whether or not it's important for you/your company to know that on 7/1/2012 the price of Product X was Y amount, or whether you only care about what the cost is NOW. It would be far easier for financial reporting if you stored the price at the time of purchase in your purchase order database (if you're doing financial reporting) but would not be necessary if your tblPRICE2 table kept a history of unit costs. If it is important there are two things you can do.

    1. Keep only one pricing record for each item for each unit of sale (individual item, pack, pallet, case, whatever) and store the cost of that item at the time of receipt/sale (this may be more difficult if you purchase or sell an item at a discount)
    2. Keep multiple pricing records for each item and store the starting date and ending date of that item at that price. This is going to be a lot clunkier for a beginner to handle but it would allow a lot more flexibility in your application over time.

    I can't really offer you a suggestion as to which would be better to you because I don't know your business or what your requirements are (simply producing a PO/bill from a printout is an entirely different matter than being able to produce monthly/weekly/annual financial reporting for instance)

    Your tblPRICE should also include a BRANDID (foreign key to your tblBRANDS) so you could narrow your searches where necessary.

    Next, you are recording sales and receipts on four tables. You don't need four, you just need 2. If you're recording incoming and outgoing P.O's and the detail (line items) you can do it with a 2 table structure like you have with tblSales (main PO information) and tblSales2 (detail of PO). You would just need 1 additional field that would indicate whether this was a receipt or sale which you could easily do by forcing data entry on a single, unified, purchase order form.

  7. #7
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125
    Thanks rpeareI will reform my Price tables to look the way you sogested. Actually you mentioned something i have been thinking of: That is, concerning a future change in the selling price. I have been thinking of how i will build the system in such a way that the system keeps track of old prices 1. but at any time a sell operation is to take place, after the user has selected the ProductName and the Unit, the Unit price should populate automatically and it should be the most updated price.2. It sells data should be stored in a manner that the new price should not change the price of the same product in an old sells. This way, future reporting will accurately be made. Do you think the tables should remain the same? I have been updating the db. If you send me your email address i will send it to you so you because its bigger than the maximum size to be uploaded here.

  8. #8
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you can store the price of the item at the time you do the sale, this would also allow you to apply a discount at the time of the purchase on either the individual item or the entire sale (if there are multiple items) The price of the item at the time of sale can come from your pricing history table just by referencing whatever the 'current' price is. You would just need a function to look up the most recent price when you're producing a purchase order.

  9. #9
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125
    Thanks rpeare

    Thats exactly how i want it to work except that i dont know the function i can attach and where i should attach it.

    If you need the DB you could send me an e-mail to : "kinason42@yahoo.com" so that i can forward it to you.

  10. #10
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You can zip up a sample of the database and upload it to this website through the 'go advanced' button at the bottom of your posting interface.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. difficulty performing a query
    By fabiobarreto10 in forum Queries
    Replies: 2
    Last Post: 12-10-2012, 07:36 AM
  2. Performing calculations from a drop down list
    By snowdrop in forum Queries
    Replies: 5
    Last Post: 01-11-2012, 06:39 AM
  3. Performing calculations in the form.
    By mulefeathers in forum Forms
    Replies: 4
    Last Post: 12-07-2011, 10:47 AM
  4. Performing count in VBA
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 08-21-2010, 07:41 PM
  5. Replies: 14
    Last Post: 06-03-2010, 06:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums