+ Reply to Thread
Results 1 to 11 of 11

updating a parent workbook from a child workbook via Userform

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    12

    updating a parent workbook from a child workbook via Userform

    Really embarrassed to even but this lousy bit of non working code out here..
    I have several instances of the child workbook with bunches of input forms. Each user inputs their own data into their own instance of this workbook. They can add records, delete records or modify existing records. Once done, upon exit, the instances of their sheet gets emailed to me so I can update the main workbook (called parent)
    I have a unique Identifier that simply is the name of the show concatenated with the start date. I want to use that field as the lookup into the parent sheet and edit the record if it is found in the parent workbook OR append it to the bottom if it is a new show.... this is the code I got and the workbooks are attached. Thanks!
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by smooth_beaker; 02-12-2013 at 10:21 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: updating a parent workbook from a child workbook via Userform

    Hi, smooth_beaker,

    please add code-tags around the button_click-procedure as requested per Forum Rule #3. This makes both reading and copying the code a lot easier.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    01-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: updating a parent workbook from a child workbook via Userform

    Thank you HaHoBe... it is now edited with tags!

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: updating a parent workbook from a child workbook via Userform

    Hi, smooth_beaker,

    maybe add a Cancel/Close button to your form as well:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    01-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: updating a parent workbook from a child workbook via Userform

    Thank you Holger,
    My biggest problem is I don't know how to code to update the 'Parent.xls' with the new info from the 'child.xls'... either update an existing record if there is a match on the unique identifier or append a new record if there is no match of the unique identifier in the parent workbook... please any insight would be amazing!
    Thank you in advance!

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: updating a parent workbook from a child workbook via Userform

    Hi, smoothsmooth_beaker,

    maybe something like this:

    Please Login or Register  to view this content.
    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    01-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: updating a parent workbook from a child workbook via Userform

    Thank you for the quick reply!!!!
    I loaded the code sample and it dies on this line:
    Please Login or Register  to view this content.
    Giving me a runtime error '91'
    Object Variable or With Block variable not set

    Thank you again!

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: updating a parent workbook from a child workbook via Userform

    Hi, smooth_beaker,

    if you copied all the code this line is in between an With..End With-statement, so Error 91 should not occur (thatīs at least what the theory says about it). I ran the code on your sample files in Excel2007 and could not find an error with it. Maybe you command these lines of code out and see if the rest works like it should:
    Please Login or Register  to view this content.
    Please mind that nearly the same code lines appear for adding the data a bit further on down on in the code.

    HTH,
    Holger

  9. #9
    Registered User
    Join Date
    01-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: updating a parent workbook from a child workbook via Userform

    Thank you SOOO Much!!! Works!

  10. #10
    Registered User
    Join Date
    07-26-2012
    Location
    delhi
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: updating a parent workbook from a child workbook via Userform

    Hi smooth_beaker,

    I tried to work with your excel sheet but it is not working as i think below mention code is not working properly.
    If you will attached the solved file it will be greatful for me as i m working on this type of project.

    Private Sub Workbook_Open()
    'Application.Visible = False
    'UserForm16.Show
    End Sub

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: updating a parent workbook from a child workbook via Userform

    Hi, pram,

    welcome to ExcelForum.

    The code you posted canīt work as the lines are commented out and will not get any action from the event (these lines of code should appear in green if you havenīt changed the settings on your PC for the VBE).

    You need to get the apostrophes away in order for the event to recognize commands that are to be executed. Make sure that the UserForm16 is in the workbook as that should be loaded (or adapt the proper name of the userform you want to show on opening).

    If you really use Excel2003 as indicated by the profile you may get a note on opening the file. You would need to enter the VBE afterwards and adjust the settings for the Office libraries as VBA will upgrade any time but canīt adjust the links to lower versions (Excel2003 is XL11, Excel2007 XL12, 2010 XL14).

    Ciao,
    Holger

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1