.VISIBLE Not Working Perfectly

  • Thread starter Faraz Ahmed Qureshi
  • Start date
F

Faraz Ahmed Qureshi

I want a few controls/text boxes to be visible only if the text box LOCATION
consists the entry Branch. Following piece of code results into be working
upon only upon the first record. In other words, once the controls become
visible they don't hide upon the next Non-Branch record unless I move the
scroll bars.

What might be the reason???

Every time I need to move within the new/current record by moving the scroll
bars to have the boxes be visible/not depending upon the LOCATION.

Private Sub Form_current()
If Me.Location <> "Branch" Then
Me.Br_T24_Code.Visible = False
Me.Branch_Name.Visible = False
Me.Address.Visible = False
Me.City.Visible = False
Me.Region.Visible = False
Me.Phone1.Visible = False
Me.Phone2.Visible = False
Me.Phone3.Visible = False
Me.Br_status.Visible = False
Me.Br_T24_Code.Enabled = False
Me.Branch_Name.Enabled = False
Me.Address.Enabled = False
Me.City.Enabled = False
Me.Region.Enabled = False
Me.Phone1.Enabled = False
Me.Phone2.Enabled = False
Me.Phone3.Enabled = False
Me.Br_status.Enabled = False
Else
Me.Br_T24_Code.Visible = True
Me.Branch_Name.Visible = True
Me.Address.Visible = True
Me.City.Visible = True
Me.Region.Visible = True
Me.Phone1.Visible = True
Me.Phone2.Visible = True
Me.Phone3.Visible = True
Me.Br_status.Visible = True
Me.Br_T24_Code.Enabled = True
Me.Branch_Name.Enabled = True
Me.Address.Enabled = True
Me.City.Enabled = True
Me.Region.Enabled = True
Me.Phone1.Enabled = True
Me.Phone2.Enabled = True
Me.Phone3.Enabled = True
Me.Br_status.Enabled = True
End If
Me.Recalc
End Sub
 
S

Stefan Hoffmann

hi Faraz,

I want a few controls/text boxes to be visible only if the text box LOCATION
consists the entry Branch. Following piece of code results into be working
upon only upon the first record. In other words, once the controls become
visible they don't hide upon the next Non-Branch record unless I move the
scroll bars.

What might be the reason???
You're using a continuous form, aren't you?

The controls on a continuous form only exist once and are simply
repainted for all records. Thus the effect you see: You can only change
all controls.

You should reconsider your form layout.
Every time I need to move within the new/current record by moving the scroll
bars to have the boxes be visible/not depending upon the LOCATION.

You can shorten this to (just to show a piece of clean code, doesn't
solve your problem):

Private Sub Form_current()

Dim isVisible As Boolean

isVisible = (Nz(Me.Location, "") = "Branch")
Me.Br_T24_Code.Visible = isVisible
Me.Branch_Name.Visible = isVisible
Me.Address.Visible = isVisible
Me.City.Visible = isVisible
Me.Region.Visible = isVisible
Me.Phone1.Visible = isVisible
Me.Phone2.Visible = isVisible
Me.Phone3.Visible = isVisible
Me.Br_status.Visible = isVisible

End Sub




mfG
--> stefan <--
 

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