By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,145 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

Select Case question

P: n/a
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
Sep 5 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ARC
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
<tr******@comcast.netwrote in message
news:68**********************************@i76g2000 hsf.googlegroups.com...
>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
Sep 5 '08 #2

P: n/a
On Sep 5, 12:04 pm, "ARC" <PCES...@PCESoft.invalidwrote:
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:68**********************************@i76g2000 hsf.googlegroups.com...
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
So simple. No wonder I missed it.Thanks.

Troy
Sep 5 '08 #3

P: n/a
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
Sep 5 '08 #4

P: n/a
ARC
Looks like you need to reference the form first, something like:

me(ctl.Name).name

<tr******@comcast.netwrote in message
news:a6**********************************@d1g2000h sg.googlegroups.com...
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
Sep 5 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.