Note that there are some explanatory texts on larger screens.

plurals
  1. POAuto Populate fields in MS Access Form
    primarykey
    data
    text
    <p>Is there a way to automatically populate fields in an MS Access form? Lets say the user makes a selection from a specific combo box on the form, is there something that can be done to automatically select the other fields on the form based on the PK?</p> <p>Id like to add that the fields to auto populate would come from various tables..</p> <p>***ammendment </p> <p>I need to return multiple values once i select a specific record in the combo box. Can someone help? The multiple values will come from a query that returns values like this: </p> <pre><code>ID Code Count 24 TST 4 24 BPB 7 24 SSS 10 </code></pre> <p>In the form, the combo box would chose the ID number. Once I choose an ID number of 24, i want to return all 3 records above that come from a query called Project_Error_Final (in this example there are 3 values to return, but i want the query to return any records with ID = 24). The VBA code i have so far is: </p> <pre><code>Private Sub cboProjectID_Change() Dim VarComboKey As Integer Dim VarObjective As Variant Dim VarStartDate As Variant Dim VarEndDate As Variant Dim VarRiskCategory As Variant Dim VarTarDatSet As Variant Dim VarErrorCount As Variant Dim VarErrorCode As Variant VarComboKey = Me.cboProjectID.Value VarObjective = DLookup("[Objective]", "[Project_HDR_T]", "[Project_ID] = " &amp; VarComboKey) Me.txtObjective = VarObjective VarStartDate = DLookup("[Start_Date]", "[Project_HDR_T]", "[Project_ID] = " &amp; VarComboKey) Me.txtStartDate = VarStartDate VarEndDate = DLookup("[End_Date]", "[Project_HDR_T]", "[Project_ID] = " &amp; VarComboKey) Me.txtEndDate = VarEndDate VarRiskCategory = DLookup("[Risk_Category]", "[Project_HDR_T]", "[Project_ID] = " &amp; VarComboKey) Me.txtRiskCategory = VarRiskCategory VartxtTarDatSet = DLookup("[Targeted_Dataset]", "[Project_Targeted_Dataset]", "[Project_ID] = " &amp; VarComboKey) Me.txtTarDatSet = VartxtTarDatSet VarErrorCount = DLookup("[Count_Error_Codes]", "[Project_Error_Final]", "[project_ID] = " &amp; VarComboKey) Me.txtErrorCount = VarErrorCount VarErrorCode = DLookup("[ErrorCode]", "[Project_Error_Final]", "[project_ID] = " &amp; VarComboKey) Me.txtErrorCode = VarErrorCode End Sub </code></pre> <p>The value in question is the VarErrorCount and VarErrorCode. In the VBA code above, only a single value is returned. But, I am looking for multiple VarErrorCount and VarErrorCode values to be returned in my form once the ID combo box field is selected. In this particular example VarErrorCode should return "TST", "BPB" and "SSS." The VarErrorCount should return the corresponding VarErrorCode values: "4","7","10"</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload