Ctl Reference

  • Thread starter Thread starter DS
  • Start date Start date
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
 
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
 
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
 
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
 

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

Back
Top