Hi,
i have 2 combobox.
Code :
Code:
Private Sub Combo_pesel_AfterUpdate()
Dim SqlString As String
Dim ComboSpolkaNr As Double
Dim rst As Recordset
If Nz(Combo_pesel, 0) = 0 Then
GoTo Koniec
End If
ComboSpolkaNr = Combo_pesel.Column(0)
SqlString = "SELECT DISTINCT QryPersonID.Person_ID, QryPersonID.Employee_ID_FK FROM QryPersonID WHERE LEN(QryPersonID.Person_ID)>1 AND [QryPersonID.Employee_ID_FK]= " & Combo_pesel & ";"
Combo_sap.RowSource = SqlString
Koniec:
End Sub
after user choice one record In combobox_pesel below combobox_sap is updated.
So If i have PESEL number 111 and and for them it is attached SAP_number 444SAP, 555SAP only these 2 values will be shown.
It is working like here:
https://www.youtube.com/watch?v=rdAqkg6bGT0
When user will choose record from combobox_sap also code will run:
Code:
Private Sub Combo_sap_AfterUpdate()
Dim SqlString As String
Dim ComboSpolkaNr As Double
Dim rst As Recordset
If Nz(Combo_sap, 0) = 0 Then
GoTo Koniec
End If
ComboSpolkaNr = Combo_sap.Column(1)
SqlString = "SELECT DISTINCT QrySurnames.PESEL, QrySurnames.Imię_Nazwisko FROM QrySurnames WHERE LEN(QrySurnames.PESEL)>1 AND [QrySurnames.PESEL]= " & ComboSpolkaNr & ";"
Combo_pesel.RowSource = SqlString
Koniec:
End Sub
and it will be filter PESEL only for choosen record.
What if user will want to have once again wide list of choices?
He updated combobox_pesel, updated combobox_sap and now he has only filter values.
How to get back to original state, original rowsource of combobox ?
I have tried with events but i failed.
Please help,
Jacek