Ctl Reference

D

DS

I'm trying to set the values on one form ApplyDiscountSelect to another
form DiscountApply, but I keepgetting an Object Error.

Dim Ctl As Control
DoCmd.Close acform,"ApplyDiscountSelect"
For Each Ctl In Forms!ApplyDiscount.Control
If Forms!ApplyDiscount.Ctl.Tag = 2 Then
Forms!ApplyDiscount.Ctl.Visible = False
ElseIf Forms!ApplyDiscount.Ctl.Tag = 3 Then
Forms!ApplyDiscount.Ctl.Visible = True
End If
Next Ctl

Any help appreciated
Thanks
DS
 
B

Barry Gilbert

Try this:

Dim Ctl As Control
DoCmd.Close acform,"ApplyDiscountSelect"
For Each Ctl In Forms!ApplyDiscount.Control
If Ctl.Tag = 2 Then
Ctl.Visible = False
ElseIf Ctl.Tag = 3 Then
Ctl.Visible = True
End If
Next Ctl

Barry
 
D

DS

Douglas J. Steele wrote:

IF I do this:

Dim Ctl As Control
For Each Ctl In Forms!ApplyDiscount.Controls
If Forms!ApplyDiscount.Ctl.Tag = 2 Then
Forms!ApplyDiscount.Ctl.Visible = True
ElseIf Forms!ApplyDiscount.Ctl.Tag = 3 Then
Forms!ApplyDiscount.Ctl.Visible = False
End If
Next Ctl

I get Application or Object defined error. Error 2465
If I do this:

Dim Ctl As Controls
For Each Ctl In Forms!ApplyDiscount.Controls
If Forms!ApplyDiscount.Ctl.Tag = 2 Then
Forms!ApplyDiscount.Ctl.Visible = True
ElseIf Forms!ApplyDiscount.Ctl.Tag = 3 Then
Forms!ApplyDiscount.Ctl.Visible = False
End If
Next Ctl

I get "Type MisMatch" Error 13

Thanks
DS
 
D

DS

Douglas said:
That needs to be

For Each Ctl In Forms!ApplyDiscount.Controls
This works.....now. For whatever reason.
Thank you everyone.
DS

If Forms!ApplyDiscount!TxtAction = 1 Then
Dim Ctl As Control
For Each Ctl In Forms!ApplyDiscount.Controls
If Ctl.Tag = 2 Then
Ctl.Visible = True
ElseIf Ctl.Tag = 3 Then
Ctl.Visible = False
End If
Next Ctl
ElseIf Forms!ApplyDiscount!TxtAction = 2 Then
For Each Ctl In Forms!ApplyDiscount.Controls
If Ctl.Tag = 3 Then
Ctl.Visible = True
ElseIf Ctl.Tag = 2 Then
Ctl.Visible = False
End If
Next Ctl
 
Top