Results 1 to 4 of 4
  1. #1
    TKTheKid is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    35

    Adding data to a table based on text boxes and comboboxes

    Hi all,

    Please refer to form formWarehouseData in my attached database file. On the very right, under "Adding Tickets," I have text boxes and comboboxes in place so a user can add data to the table tableWarehouseData.

    My question is, what would the code be like for commandAdd_Click to add the data to tableWarehouseData? I have the code for the message box in place there just like I have in commandEdit_Click, but I'm not sure how to actually get the data into tableWarehouseData.

    Thank you,


    Tony
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Simplest is to bind the controls to fields and move to new record. Then code in the button simply saves the record: DoCmd.RunCommand acCmdSaveRecord

    If you want to use unbound controls (Quantity would also need to be unbound), options:
    1. move to new record, populate fields with values entered in controls, example: Me!Ticket = Me.textAddTicket
    2. run SQL INSERT action
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    TKTheKid is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    35
    Quote Originally Posted by June7 View Post
    Simplest is to bind the controls to fields and move to new record. Then code in the button simply saves the record: DoCmd.RunCommand acCmdSaveRecord

    If you want to use unbound controls (Quantity would also need to be unbound), options:
    1. move to new record, populate fields with values entered in controls, example: Me!Ticket = Me.textAddTicket
    2. run SQL INSERT action
    So for option 2, there would be code using INSERT that could enter data from my text boxes and comboboxes directly into tableWarehouseData? I think that's the better option. What would that look like?

    Thanks.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If Not IsNull(Me.textAddTicket) AND Not IsNull(Me.textAddLocation) AND Not IsNull(Me.comboAddUPC) AND Not IsNull(Me.textAddQuantity) Then
    CurrentDb.Execute "INSERT INTO tblWarehouseData(Ticket, Loc, Article, Quantity) VALUES(" & Me.textAddTicket & ", '" & Me.textAddLocation & "', '" & Me.comboAddUPC & "', " & Me.textAddQuantity & ")"
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  2. Replies: 7
    Last Post: 09-06-2011, 08:00 PM
  3. Replies: 0
    Last Post: 06-15-2011, 07:02 AM
  4. Replies: 15
    Last Post: 04-01-2011, 11:41 AM
  5. Replies: 1
    Last Post: 11-04-2010, 12:57 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