問題描述
如何根據來自兩個組合框的輸入隱藏/取消隱藏子表單? (How do I hide/unhide a subform based on the input from two comboboxes?)
p>當前子表單設置為 Visible:No 所以什麼也沒有出現。如果我改變它,它不會消失,空的子表單仍然可見。這不是問題,除非我需要將此表單用於另一個查詢,並希望在第二個子表單準備好使用時將它們分層。</p>
稍後將使用此表單推送根據不同的子表單對錶進行 UPDATE SET。
代碼是否有明顯錯誤,或者我錯過了某處的設置?
參考解法
方法 1:
You can try this:
Private Sub updateStates()
Me!qry_TrainingsSU.Form.Requery
If (Me.cbo_EmployeeLookup.Value <> "" AND Me.cbo_TrainingName.Value <> "") Then
Me!qry_TrainingsSU.Visible = True
Else
Me!qry_TrainingsSU.Visible = False
End If
End Sub
Private Sub cbo_EmployeeLookup_AfterUpdate()
updateStates
End Sub
Private Sub cbo_TrainingName_AfterUpdate()
updateStates
End Sub
</code></pre>
Forms!qry_TrainingsSU
searches form opened as main form, not a subform.
(by Christopher J. Joubert、jacouh)
參考文件