Re: Select Case question



On Sep 5, 12:04 pm, "ARC" <PCES...@xxxxxxxxxxxxxxx> wrote:
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_...@xxxxxxxxxxx> wrote in message

news:68b5b06c-218a-435d-9e77-5669fb928a92@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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
.



Relevant Pages

  • Re: Select Case question
    ... Case acTextBox, acComboBox ... Case acCheckBox ... In the header, I have a text box with the control ...
    (comp.databases.ms-access)
  • Re: Anyone spot whats worng here?
    ... acTextBox Or ctrl.ControlType = acComboBox) Then _ ... Doug Steele, Microsoft Access MVP ... (no e-mails, please!) ...
    (microsoft.public.access.formscoding)
  • Re: Anyone spot whats worng here?
    ... acTextBox Or ctrl.ControlType = acComboBox) Then _ ... (no e-mails, please!) ... For Each ctrl In Detail.Controls ...
    (microsoft.public.access.formscoding)