A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Referencing controls in a Selection Criteria form for Reports



 
 
Thread Tools Display Modes
  #1  
Old June 13th, 2004, 08:41 PM
Barry G. Sumpter
external usenet poster
 
Posts: n/a
Default 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  
Old June 13th, 2004, 09:01 PM
Albert D. Kallal
external usenet poster
 
Posts: n/a
Default 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  
Old June 15th, 2004, 06:15 AM
Barry G. Sumpter
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:27 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.