Search code examples
ms-accessms-access-2016

Pass parameters from one combo box to another using two forms in Microsoft Access


Just started working with Access 2016 for a project I am on.

How can I pass selected data from one form in access to another?

That Selection will be the determining factor on what data is presented in drop down menus. Basically, if I select a department, I want that departments data to be the "select from" data on the next.

I'm not really sure if this is a clear question, so I've added pictures.

The Goal is to not have to create a new form for every department.

Form 1 - Department Selector

Form 2 - Pic from Data based on department

Update:

So I am able to link the department combo box with the lineid box with the following Query

SELECT DISTINCT Line.lineName, Department.departmentName
 FROM Line INNER JOIN Department ON Line.departmentID = Department.departmentID
 WHERE (((Department.departmentName)=[Forms]![Production_Select_Data_Input_Destination].[OpenArgs]));

Image3 enter image description here

I need to get the parameter passed so this is not prompt and the combo box for lineId loads a select list of lineId's that are within the selected department.


Solution

  • I figured it out using

    Private Sub btnEnterDataInput_Click()
    
     DoCmd.OpenForm "frmDataInput", , , , , , OpenArgs:=cboDepartmentName
    
    End Sub
    

    In my first form, and

    [Forms]![frmSelectDataInput]![cboDepartmentName]
    

    in my second form combobox row source query.

    in my second form.