Pass new Form Value to the form that opened it

Access 2013.  I have two tables -  CompanyInfo & EmployeeInfo.  A company can have multiple employees.

I have a form EmployeeInput where the use can PICK the EXISTING company that a new employee works for from a Combo box of CompanyNames.  The user can double click the combobox if the Company doesn't exist, and the CompanyInput form will open and let the user enter all the information about this new company.  I have a button on the CompanyInput form to save the record and close the form "to return to employee input".  When the CompanyInput form closes, I would like for the combobox on the EmployeeInput form which PREVIOUSLY did not contain the CompanyName to now SHOW the CompanyName that was just created on the CompanyInput form, along with the address, phone number, and other information from the company that was created.

I have seen some things that looked like what I needed, but so far have not been able to get it to work.

Thanks for any and all help!
KevinAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
when you open the form, use
DoCmd.OpenForm "f_INVOICES", , , , , acDialog

Open in new window

well, you may have parameters -- in which case, do not leave those arguments blank -- main thing is to specify acDialog

this means control will not be passed back to the calling code until the form is closed.

then:
me.controlname.requery

Open in new window

WHERE
controlname is the NAME property of the combo to rebuild the list for
KevinAuthor Commented:
So

1. me.controlname.requery would be the last line in the code that Opened the second form for input?

2.  I would put the parameters that I wanted passed (such as address, city, state, country) and then just add acDialog as the last parameter?
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
1. no, controlname is what you want to requery -- that would be the NAME property for the control containing company

To find this out: go to the DESIGN view of the form

show the property sheet if it is not already showing by pressing ALT-ENTER
(the property sheet shows additional details for whatever is selected)

then click on the control with company and get the Name from the first property listed on the OTHER (or ALL) tab

2. yes, count the commas -- or just keep pressing comma until Intellisense shows acDialog as a parameter ;)

to make Intellisense show if it doesn't launch automatically, press Ctrl-Spacebar
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

KevinAuthor Commented:
This was my code on the form to add company data:

Private Sub cboCompanyName_DblClick(Cancel As Integer)
    Dim rs As DAO.Recordset
    Dim strWhere As String
    Const strcTargetForm = "CompanyInputNoEmployee"
    
    'Set up to search for the current customer.
    If Not IsNull(Me.CompanyName) Then
        strWhere = "CompanyName = """ & Me.CompanyName & """"
    End If
    
    'Open the editing form.
    If Not CurrentProject.AllForms(strcTargetForm).IsLoaded Then
        DoCmd.OpenForm strcTargetForm
    End If
    
    With Forms(strcTargetForm)
    
        'Save any edits in progress, and make it the active form.
        If .Dirty Then .Dirty = False
        .SetFocus
        If strWhere <> vbNullString Then
            'Find the record matching the combo.
            Set rs = .RecordsetClone
            rs.FindFirst strWhere
            If Not rs.NoMatch Then
                .Bookmark = rs.Bookmark
            End If
        Else
            'Combo was blank, so go to new record.
            RunCommand acCmdRecordsGoToNew
        End If
    End With
    Set rs = Nothing
End Sub

Open in new window


which gave me a blank form for a new record.  When I added the commas and the acDialog to the statement, the form did open, but was populated with a company, instead of being ready for a new record...
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
to open a form in dialog mode, for adding records:
DoCmd.OpenForm "myFormname", , , ,acFormAdd , acDialog

Open in new window

WHERE
myFormname is the name of the form you want to open

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KevinAuthor Commented:
Thanks!
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
you're welcome ~ happy to help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.