Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2011
    Posts
    7

    Question Unanswered: Adding data using textboxes and comboboxes on a form

    I'm having trouble writing the code in the commandbutton to copy the data from the form to the desired forms. None of the textboxes or combo boxes are bounded because I need to to change information on various forms. The combo boxes take information from a table. When I click the commandbutton, there is no error message, but the information isn't added to the "Takeout_History" table. In fact, nothing happens. This is my code so far:

    Code:
    Private Sub Command17_Click()
    
    Dim rstTakeout_History As DAO.Recordset
    
    Set rstTakeout_History = CurrentDb.OpenRecordset("Takeout_History")
    
    
    With rstTakeout_History
        .AddNew
        !Date.Value = Text18
        !Name_Worker = Text7
        !Name_Product = Combo0
        !Name_Model = Combo2
        !Amount = Text15
        !Unit = Text12
        .Update
    End With
    
    End Sub
    Update: Turns out it works, but the results don't show up in the table until I close it and reopen it. Is there anyway I can have it show up immediately after I click? I think the .update did that for me.
    Last edited by beanhead0321; 07-18-11 at 05:48.

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Most of us don't work directly in tables, and don't let users in them. The data should be available to any form/report requiring it. If a form is already open, a Requery should get the new record.
    Paul

  3. #3
    Join Date
    Jul 2011
    Posts
    7
    So what would be a better way to do this? I have a form that has two combo boxes to run a query to pick out an object from the inventory table. Then the about that is taken out at that time of that object will be put in a textbox and subtracted from the amount in the inventory (I haven't figured out how to do this yet. I'm fairly new to access. Any help on this part would be great because I'm gonna be posting on here about it eventually). This information, the two combo boxes and the textbox, will be entered into a new table and recorded along with the time.
    And can access do math like excel? My idea for the first part was to run a separate query from the inventory table and use the two combo boxes as criteria. This will isolate one single object in the query. Then I would apply the subtraction to the item in the query and that will update the same item in the inventory table. Is that possible?

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Inventory apps are not for the faint-of-heart. I would generally advise against storing the quantity on hand, and I haven't in the inventory apps I've created. You calculate it from transactions. Here's an often cited link that discusses the topic:

    Allen Browne - Inventory Control: Quantity on Hand
    Paul

  5. #5
    Join Date
    Jul 2011
    Posts
    7
    Alright, Thanks a bunch. This looks intense. I think I might just start over... XD this seems like a smarter way to do it though. Thanks for the resource and help

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •