If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Adding data using textboxes and comboboxes on a form

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-18-11, 04:28
beanhead0321 beanhead0321 is offline
Registered User
 
Join Date: Jul 2011
Posts: 7
Question 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 04:48.
Reply With Quote
  #2 (permalink)  
Old 07-18-11, 13:17
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
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
Reply With Quote
  #3 (permalink)  
Old 07-18-11, 19:51
beanhead0321 beanhead0321 is offline
Registered User
 
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?
Reply With Quote
  #4 (permalink)  
Old 07-18-11, 20:01
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
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
Reply With Quote
  #5 (permalink)  
Old 07-18-11, 21:09
beanhead0321 beanhead0321 is offline
Registered User
 
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
Reply With Quote
Reply

Tags
add, combobox, data, form, textbox

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On