0
votes

So here is the datasheet form

enter image description here

In the combo box I set value based on Employee ID

enter image description here

As of now I looked at .CurrentRecord but that returns the row number not the ID. I can succesfully pass the .CurrentRecord Value to the form and set that as the ComboBox problem is the number of row is not necessarily equal to the Employee ID

What I want is the User to be able to select a record on the sheet that is an employee and when the User presses the Trainings button it shows the second form with combo box set to that employees ID.

1

1 Answers

0
votes

Recording value so it's not lost when button is clicked with timer event, timing is set to 500

Private Sub Form_Timer()
    value = Me.EID.value
End Sub

I passed the value using DoCmd.OpenForm last argument.

Private Sub trainings_Click()
    On Error GoTo trainings_Click_Err

    ' _AXL:<?xml version="1.0" encoding="UTF-16" standalone="no"?>
    ' <UserInterfaceMacro For="show_trainings" xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application"><Statements><Action Name="OpenForm"><Argument Name="FormName">Employee
    ' _AXL:Trainings</Argument><Argument Name="WhereCondition">="[ATTUID]="  &amp;"'" &amp;[ATTUID] &amp; "'"</Argument></Action></Statements></UserInterfaceMacro>
    DoCmd.OpenForm "Add Training", acNormal, "", "", , acNormal, value


trainings_Click_Exit:
    Exit Sub

trainings_Click_Err:
    MsgBox Error$
    Resume trainings_Click_Exit

End Sub

and at last I read the Argument and set the Combo box value and for the dependent listboxes I called requery

Private Sub Form_Open(Cancel As Integer)
    If Not IsNull(Me.OpenArgs) Then
        Me.cboEmp = Me.OpenArgs
        Me.List14.Requery
        Me.List18.Requery
    End If
End Sub