Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old September 5th, 2008, 05:05 PM
troy_lee@comcast.net
Guest
 
Posts: n/a
Default Select Case question

I have a form that acts a filter. All of the filtering objects are in
the header and the results are displayed in a continuous form in the
detail section.

In the header, I have a text box (txtCountRecords) with the control
source ="Your filter returned " & Count(*) & " units." Everything
works great until I clear the filter and null out all of the objects
in the header. Here is the code for that:

Private Sub cmdReset_Click()
'Purpose: Clear all the search boxes in the Form Header, and show
all records again.
Dim ctl As Control

'Clear all the text and combo boxes in the Form Header section.

For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
Case acCheckBox
ctl.Value = False
End Select
Next

'Clear the list boxes with the public function fSelectAll.
Call fSelectAll(Me.lstCustomer, False)
Call fSelectAll(Me.lstPartNo, False)
Call fSelectAll(Me.lstPriority, False)
Call fSelectAll(Me.lstWIP, False)

'Reset the value of the Record Source combo box.
Me.cboRecordSource.Value = "All Unshipped Units"

'Remove the form's filter.
Me.Filter = "(False)"
Me.FilterOn = True
Me.txtCountRecords.Visible= False

End Sub

This is the portion of code that keeps failing.

For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null

I can not null out the text box for counting records. I can only guess
it's because I have a function in the control source. That's fine.
What I really want to do is exclude this one text box from being
evaluated by the Select Case statement. The name of the text box is
txtCountRecords. How do I do this?

Thanks in advance.

Troy Lee
  #2  
Old September 5th, 2008, 05:05 PM
ARC
Guest
 
Posts: n/a
Default Re: Select Case question

Couldn't you do this?:

Select Case ctl.ControlType
Case acTextBox, acComboBox
if ctl.name <"txtCountRecords" then
ctl.Value = Null
end if
Case acCheckBox
ctl.Value = False
End Select


<troy_lee@comcast.netwrote in message
news:68b5b06c-218a-435d-9e77-5669fb928a92@i76g2000hsf.googlegroups.com...
Quote:
>I have a form that acts a filter. All of the filtering objects are in
the header and the results are displayed in a continuous form in the
detail section.
>
In the header, I have a text box (txtCountRecords) with the control
source ="Your filter returned " & Count(*) & " units." Everything
works great until I clear the filter and null out all of the objects
in the header. Here is the code for that:
>
Private Sub cmdReset_Click()
'Purpose: Clear all the search boxes in the Form Header, and show
all records again.
Dim ctl As Control
>
'Clear all the text and combo boxes in the Form Header section.
>
For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
Case acCheckBox
ctl.Value = False
End Select
Next
>
'Clear the list boxes with the public function fSelectAll.
Call fSelectAll(Me.lstCustomer, False)
Call fSelectAll(Me.lstPartNo, False)
Call fSelectAll(Me.lstPriority, False)
Call fSelectAll(Me.lstWIP, False)
>
'Reset the value of the Record Source combo box.
Me.cboRecordSource.Value = "All Unshipped Units"
>
'Remove the form's filter.
Me.Filter = "(False)"
Me.FilterOn = True
Me.txtCountRecords.Visible= False
>
End Sub
>
This is the portion of code that keeps failing.
>
For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
>
I can not null out the text box for counting records. I can only guess
it's because I have a function in the control source. That's fine.
What I really want to do is exclude this one text box from being
evaluated by the Select Case statement. The name of the text box is
txtCountRecords. How do I do this?
>
Thanks in advance.
>
Troy Lee
  #3  
Old September 5th, 2008, 05:55 PM
troy_lee@comcast.net
Guest
 
Posts: n/a
Default Re: Select Case question

On Sep 5, 12:04 pm, "ARC" <PCES...@PCESoft.invalidwrote:
Quote:
Couldn't you do this?:
>
Select Case ctl.ControlType
Case acTextBox, acComboBox
if ctl.name <"txtCountRecords" then
ctl.Value = Null
end if
Case acCheckBox
ctl.Value = False
End Select
>
<troy_...@comcast.netwrote in message
>
news:68b5b06c-218a-435d-9e77-5669fb928a92@i76g2000hsf.googlegroups.com...
>
Quote:
I have a form that acts a filter. All of the filtering objects are in
the header and the results are displayed in a continuous form in the
detail section.
>
Quote:
In the header, I have a text box (txtCountRecords) with the control
source ="Your filter returned " & Count(*) & " units." Everything
works great until I clear the filter and null out all of the objects
in the header. Here is the code for that:
>
Quote:
Private Sub cmdReset_Click()
'Purpose: Clear all the search boxes in the Form Header, and show
all records again.
Dim ctl As Control
>
Quote:
'Clear all the text and combo boxes in the Form Header section.
>
Quote:
For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
Case acCheckBox
ctl.Value = False
End Select
Next
>
Quote:
'Clear the list boxes with the public function fSelectAll.
Call fSelectAll(Me.lstCustomer, False)
Call fSelectAll(Me.lstPartNo, False)
Call fSelectAll(Me.lstPriority, False)
Call fSelectAll(Me.lstWIP, False)
>
Quote:
'Reset the value of the Record Source combo box.
Me.cboRecordSource.Value = "All Unshipped Units"
>
Quote:
'Remove the form's filter.
Me.Filter = "(False)"
Me.FilterOn = True
Me.txtCountRecords.Visible= False
>
Quote:
End Sub
>
Quote:
This is the portion of code that keeps failing.
>
Quote:
For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
>
Quote:
I can not null out the text box for counting records. I can only guess
it's because I have a function in the control source. That's fine.
What I really want to do is exclude this one text box from being
evaluated by the Select Case statement. The name of the text box is
txtCountRecords. How do I do this?
>
Quote:
Thanks in advance.
>
Quote:
Troy Lee
So simple. No wonder I missed it.Thanks.

Troy
  #4  
Old September 5th, 2008, 06:05 PM
troy_lee@comcast.net
Guest
 
Posts: n/a
Default Re: Select Case question

On Sep 5, 12:49 pm, troy_...@comcast.net wrote:

if ctl.name <"txtCountRecords" then
ctl.Value = Null

I tried this and Access tells me I can't assign a value to this
object. Any ideas?

Troy
  #5  
Old September 5th, 2008, 06:25 PM
ARC
Guest
 
Posts: n/a
Default Re: Select Case question

Looks like you need to reference the form first, something like:

me(ctl.Name).name



<troy_lee@comcast.netwrote in message
news:a62544e8-6ae3-46a5-9805-f536b6df1613@d1g2000hsg.googlegroups.com...
Quote:
On Sep 5, 12:49 pm, troy_...@comcast.net wrote:
>
if ctl.name <"txtCountRecords" then
ctl.Value = Null
>
I tried this and Access tells me I can't assign a value to this
object. Any ideas?
>
Troy
 

Bookmarks

Thread Tools

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles