Clearing controls on a subform

S

SAC

I'm attempting to clear the controls on a subform manually. (They are not
linked).

I get an error that I have an invalid reference to the property
From/Report - error 2455

Here's what I've got:

If Me.NewRecord Then
Dim cntrl As Access.Control

'Clear controls on subform

For Each cntrl In
Forms![frmBookingShows]![frmBookingShowsFacilities].Controls
If cntrl.ControlType = acTextBox Or cntrl.ControlType =
acComboBox Or cntrl.ControlType = acCheckBox Or cntrl.ControlType =
acListBox Then
cntrl.Value = Null
End If
Next cntrl
End If

What am I doing incorrectly?

Thanks.

Appreciate your help!
 
G

Guest

Try replacing with this:
Forms![frmBookingShows]![frmBookingShowsFacilities].Form.Controls
 
S

SAC

Same Error. I copied the reference from one in a previous line of the code
that works fine so I don't think it's a typo.

Anything else I could try or maybe something I could do to the reference?

Thanks.

SteveM said:
Try replacing with this:
Forms![frmBookingShows]![frmBookingShowsFacilities].Form.Controls
--
Steve McGuire
MCSD, MCAD, MCP


SAC said:
I'm attempting to clear the controls on a subform manually. (They are
not
linked).

I get an error that I have an invalid reference to the property
From/Report - error 2455

Here's what I've got:

If Me.NewRecord Then
Dim cntrl As Access.Control

'Clear controls on subform

For Each cntrl In
Forms![frmBookingShows]![frmBookingShowsFacilities].Controls
If cntrl.ControlType = acTextBox Or cntrl.ControlType =
acComboBox Or cntrl.ControlType = acCheckBox Or cntrl.ControlType =
acListBox Then
cntrl.Value = Null
End If
Next cntrl
End If

What am I doing incorrectly?

Thanks.

Appreciate your help!
 
S

SAC

I just double checked the reference and got it from the expression builder.
Here's what I have and am still getting the error:

If Me.NewRecord Then
Dim cntrl As Access.Control
For Each cntrl In
[Forms]![frmBookingShows]![frmBookingShowsAssociations].[Form].Controls
If cntrl.ControlType = acTextBox Or cntrl.ControlType =
acComboBox Or cntrl.ControlType = acCheckBox Or cntrl.ControlType =
acListBox Then
cntrl.Value = Null
End If
Next cntrl
End If




SteveM said:
Try replacing with this:
Forms![frmBookingShows]![frmBookingShowsFacilities].Form.Controls
--
Steve McGuire
MCSD, MCAD, MCP


SAC said:
I'm attempting to clear the controls on a subform manually. (They are
not
linked).

I get an error that I have an invalid reference to the property
From/Report - error 2455

Here's what I've got:

If Me.NewRecord Then
Dim cntrl As Access.Control

'Clear controls on subform

For Each cntrl In
Forms![frmBookingShows]![frmBookingShowsFacilities].Controls
If cntrl.ControlType = acTextBox Or cntrl.ControlType =
acComboBox Or cntrl.ControlType = acCheckBox Or cntrl.ControlType =
acListBox Then
cntrl.Value = Null
End If
Next cntrl
End If

What am I doing incorrectly?

Thanks.

Appreciate your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top