如何根據來自兩個組合框的輸入隱藏/取消隱藏子表單? (How do I hide/unhide a subform based on the input from two comboboxes?)


問題描述

如何根據來自兩個組合框的輸入隱藏/取消隱藏子表單? (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 &lt;&gt; &quot;&quot; AND Me.cbo_TrainingName.Value &lt;&gt; &quot;&quot;) 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. Joubertjacouh)

參考文件

  1. How do I hide/unhide a subform based on the input from two comboboxes? (CC BY‑SA 2.5/3.0/4.0)

#ms-access-forms #vba #ms-access






相關問題

DLookup 表達式總是返回相同的記錄 (DLookup expression always returning the same record)

MS-Access VBA - 如何將文本框使用的當前查詢字段名稱分配給變量 (MS-Access VBA - How to assign the current query field name used by a textbox to a variable)

MS Access 錯誤 3188:無法更新;當前被這台機器上的另一個會話鎖定 (MS Access Error 3188: Could not update; currently locked by another session on this machine)

將文本框值分配給多個表/查詢字段值 (Assigning a textbox value to a multiple table/query field values)

從訪問表單的文本字段傳遞開始和結束日期參數 (Pass start and end date parameter from text field of access form)

如何根據來自兩個組合框的輸入隱藏/取消隱藏子表單? (How do I hide/unhide a subform based on the input from two comboboxes?)

ms訪問表單:組合框到多選下拉菜單 (ms access form: combobox to multiselect dropdown menu)

訪問表單宏 Where 條件 (Access Form Macro Where Condition)

(Microsoft Access) 如何輸入多個新記錄,其中 5 個字段中有 2 個被重置 ((Microsoft Access) How to Input multiple new records with 2 out of 5 fields from being reset)

帶有“新記錄”按鈕的更新前 (BeforeUpdate with a "new record" button)

MS Access 表單日期/時間輸入問題 (MS Access Forms Date/Time Entry Trouble)







留言討論