On main form i have two combobox , subform is in datasheat mode and one of filed is combobox, so this combo in subform is filtered by two combo from main form. problem is when go to another main form record or close and open form subform combo is empty until i dont click on any field in subform.
This is code for filtering subform combo :
I know this happened because RowSource of subform combo is populating on Enter event for subform.
maybe someone have better solution how to archive this filtering.
p.s - I tryd on Current Event of Parent form, this way will work for record what was enter bifore , but when i create new Parent record , combobox on subform is empty.
Thanks
Fule
This is code for filtering subform combo :
Code:
rivate Sub subSpReqDt_Enter()
On Error GoTo err_Subform
Dim strSQL As String
strSQL = "SELECT tblSpProduct.fkMaker_ID, tblSpProduct.fkPart_ID, tblSpareItm.SpareItm_ID," _
& " tblSpareItm.SpItemName, tblSpareItm.SpItemPart, tblSpareItm.IssaCode, tblSpareItm.Units" _
& " FROM tblSpProduct INNER JOIN tblSpareItm ON tblSpProduct.SpProduct_ID = tblSpareItm.fkSpProduct_ID" _
& " WHERE [fkMaker_ID]=" & Me.cboMaker & " AND [fkPart_ID]=" & Me.cboPart
Forms!frmSpReq!subSpReqDt![cboItemName].RowSource = strSQL
Forms!frmSpReq!subSpReqDt![cboItemName].Requery
exit_Subform:
Exit Sub
err_Subform:
MsgBox Err.Description, vbOKOnly, " Error : " & Err.Number
Resume exit_Subform
End Sub
maybe someone have better solution how to archive this filtering.
p.s - I tryd on Current Event of Parent form, this way will work for record what was enter bifore , but when i create new Parent record , combobox on subform is empty.
Thanks
Fule