Results 1 to 13 of 13
  1. #1
    Dormie is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    39

    Add Data from Form to SubForm; Text Box not Saving

    Hi,

    I'm trying to create a Form to add multiple data rows to a Table.

    I've created the Form from tSupplier and a subform from tInventory, I've linked a couple of text box/columns from the form to the subform through the Subform wizard. I've also created a separate date textbox in the Form that will add to a column in the subform. However what I need help with is I can't get that date textbox to save into the main tInventory table. Everything else will save besides that.

    Basically, I'm trying to create a form to add multiply inventory to my tInventory table using a form from my tSupplier table. Please let me know if there is a better way in handling this.



    Thank you.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,540
    The textbox is bound to field?

    Why are you linking multiple fields?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    Dormie is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    39
    Hi, Thank you for the quick response.

    The Date Column in subform tInventory is bound to Date in the Main Form. When entering the date in the Main Form it transfers down to the subform perfectly. However, It doesn't save into tInventory when I go to the actual table. The Text Box in Main Form is not bound.

    I don't really know why I'm linking multiple fields. But currently, I'm thinking one field from the main form to sub form and I wanted to create three text boxes in the main form to add information automatically to the subform per multiple entry. Which I seem to get working fine besides it not saving to the actual table.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,540
    What do you mean the subform control is bound to Date in Main Form? You have an expression in textbox ControlSource? Calculated values are not automatically saved anywhere. This requires code.
    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.

  5. #5
    Dormie is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    39
    Yes, I have an expression in the subform ControlSource that = the date textbox in the Main Form.

    Well, that's my problem that the Calculated values aren't automatically saved anywhere. How difficult is that code? I only want to save it to the tInventory table in that column. As you can probably tell, I'm just getting started in access.

    What I'm trying to do is figure out a way to add multiple data(inventory) into the tInventory. I had a couple of fields that would be added to each data/inventory row which I was using with textboxes in the Main Form to do that (but they obviously weren't saving).

    Should I have this all set up a completely different way? I've looked at a couple of different templates and they all set up with a quantity/reorder type system. I don't need anything near that sophisticated as all the inventory is unique and I don't reorder anything.

    Any ideas or pointed in any direction is appreciated.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,540
    The code isn't difficult if you understand programming. The code can be macro or VBA. I use only VBA. In the form BeforeUpdate event VBA procedure:

    Me!datefieldname= Me.textboxname

    What is the date for - date of entry, date of purchase? If you just want to save the current date, can set textbox DefaultValue property to: Date().
    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.

  7. #7
    Dormie is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    39
    Great June7, Thank you very much!

    I'm not very familar with programming but I've done some basic macro with excel. Where exactly should that code be added? BeforeUpdate in the Subform column of DateReceived? And Me refers to what? Also, Can I do this through the macro builder? And it wouldn't work through the expression building? Can I type it right into the BeforeUpdate field?

    Yes, this is the date purchased sometimes current date, sometimes not.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,540
    Excel macros are really VBA procedures. Macros in Access are very different.

    I suggested code go in the form BeforeUpdate VBA procedure. For VBA, select [Event Procedure] in the event property. Click the ellipsis (...) to open the VBA editor. Type code in procedure.

    Me. is shorthand alias for the form or report the code is behind.
    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.

  9. #9
    Dormie is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    39
    Thank you again.

    I've been playing around with it and can't get it to work.

    I've gone to the VBA Editor: Under Mircosoft Access Class Objects (right?)

    Should I be working in -
    Form_NewProduct <- Main Form
    Form_InventoryAdd <- SubForm


    Should it literally read this?

    Private Sub Form_BeforeUpdate(Cancel As Integer)

    Me!DateReceived = Me.Text37

    End Sub

    Or

    Private Sub Form_BeforeUpdate(Cancel As Integer)

    tInventory!DateReceived = Me.Text37

    End Sub


    tInventory being the main table I'm trying to save it back to.

    Sorry for the basic questions.............................

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,540
    Code behind the subform.

    The first code example - assuming subform is bound to tInventory.

    The second example won't work at all.
    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.

  11. #11
    Dormie is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    39
    I've been working on it.

    I'm getting a
    Compile Error:
    Method or Data member not found

    This seems to be on the text37 which is in the Main Form where I enter the date, that date is then added through an expression to the Sub Form DateReceived Column.

    Can't seem to figure out what I'm doing wrong.

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,540
    Don't refer to the main form textbox, refer to the subform textbox that has the expression that references the main form textbox.
    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.

  13. #13
    Dormie is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    39
    Thank you for your help June7!

    Unfortantly, I haven't figured out what I'm doing wrong. But, I'm working on it today!

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

Similar Threads

  1. Replies: 7
    Last Post: 10-17-2012, 11:59 AM
  2. Saving data back into a table from a form
    By skyview chick in forum Forms
    Replies: 22
    Last Post: 08-15-2012, 05:43 PM
  3. Exit without saving Subform
    By sk88 in forum Access
    Replies: 5
    Last Post: 05-03-2012, 11:55 AM
  4. Replies: 1
    Last Post: 04-19-2011, 01:55 PM
  5. Replies: 9
    Last Post: 09-25-2010, 10:14 AM

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 - Senior Forums