If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Referencing controls in a Selection Criteria form for Reports
Hi all,
I'm using the form generated in the Switchboard manager. I've added a few combo boxes for selection criteria: cboUser cboCompany cboProject cboTask I've a very simple report which just shows what user is assigned to what company, project, task. At the top of the report I want to show the selection criteria. To build the selection criteria text I execute a routine after every cboXXXX_Change The problem: To retrieve the text from each combo box I have to use: cboxxx.setfocus The setfocus causes a lot of flickering on the form. as in: Sub BuildReportCriteriaDisplays() Dim strLabels As String Dim strData As String txtUser.SetFocus If Trim(txtUser.Text) "" Then strLabels = "User :" strData = txtUser.Text End If cboCompany.SetFocus If cboCompany.Value "" Then If Trim(strLabels) "" Then strLabels = strLabels & vbCrLf & "Company :" strData = strData & vbCrLf & cboCompany.Text Else strLabels = "Company :" strData = cboCompany.Text End If End If etc.... Is there another way to reference properties a control on a form? Thanks, Barry G. Sumpter |
#2
|
|||
|
|||
Referencing controls in a Selection Criteria form for Reports
The .text property of a control is ONLY valid while the control has focus.
You want as a matter of general coding to use: If cboCompany.Value "" Then strData = cboCompany Just use cboCompany or cboCompany.Value Both are the same.Both can be use to set, or get values. So, you RARELY will use .text. The .text should only be used for events like on-change when you need to work with the text of a control..but the control has NOT yet been updated... So, in 99% of all you coding ...just use the control name, and you do NOT have to worry about focus... -- Albert D. Kallal (Access MVP) Edmonton, Alberta Canada http://www.attcanada.net/~kallal.msn |
#3
|
|||
|
|||
Referencing controls in a Selection Criteria form for Reports
Cable modem has been down for the last day...
Thanks Albert that was it exactly... "Albert D. Kallal" wrote in message ... The .text property of a control is ONLY valid while the control has focus. You want as a matter of general coding to use: If cboCompany.Value "" Then strData = cboCompany Just use cboCompany or cboCompany.Value Both are the same.Both can be use to set, or get values. So, you RARELY will use .text. The .text should only be used for events like on-change when you need to work with the text of a control..but the control has NOT yet been updated... So, in 99% of all you coding ...just use the control name, and you do NOT have to worry about focus... -- Albert D. Kallal (Access MVP) Edmonton, Alberta Canada http://www.attcanada.net/~kallal.msn |
Thread Tools | |
Display Modes | |
|
|