Conditional Visibility Based on Value of Another Field

kryptkitten

Registered User.
Local time
Today, 06:12
Joined
Jul 19, 2010
Messages
34
Hi All,

So I am sure there has to be a way to do this just not clear on the best approach. I am working in Access 2000.

I have a report that I want to set a bunch of fields only be visible if a status is set to a particular value:

If status = "green" then make delay reason textbox and delay assignment textbox not visible else make them visible.

Not sure if this could be done in the Control Source for status or if it would be better suited elsewhere since I have 4 delay reason textboxes and 4 delay assignment textboxes (not my design choice working with what I have).

Thanks!

Stacy
 
You can do this with an if statement in vb using the .visible property of the textboxes

Something like
Code:
if status="green" then
textbox1.visible=false
textbox2.visible=false
else
textbox1.visible=true
textbox2.visible=true
end if

Oh and you can put it in the oncurrent event of the form
 
Don't know where to find the oncurrent event, is that only applicable to forms or as that for reports as well? I don't see it as a property anywhere.

Thanks!

Stacy
 
im sorry, i didnt see you wanted it on a report..

you can do it in the on format event of the report
 
Okay spoke too soon! It blew up! It worked a few times so not sure what happened there.

Here is what I have:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If [RESOURCE MANAGER STATUS] = "Green" Then
[DELAY REASONS1].Visible = False
[DELAY REASONS2].Visible = False
[DELAY REASONS3].Visible = False
[DELAY REASONS4].Visible = False
[DELAY ASSIGNMENT1].Visible = False
[DELAY ASSIGNMENT2].Visible = False
[DELAY ASSIGNMENT3].Visible = False
[DELAY ASSIGNMENT4].Visible = False
Else
[DELAY REASONS1].Visible = True
[DELAY REASONS2].Visible = True
[DELAY REASONS3].Visible = True
[DELAY REASONS4].Visible = True
[DELAY ASSIGNMENT1].Visible = True
[DELAY ASSIGNMENT2].Visible = True
[DELAY ASSIGNMENT3].Visible = True
[DELAY ASSIGNMENT4].Visible = True
End If
End Sub

The error I am getting is:

Error accessing file. Network connection may have been lost.

So far I have tried rebuilding the report with the exception of adding this code in and it works just fine. I also tried is deleting that code in the original report to see if the report will run and it does. So definitely seems to be something specific to that code. What's wrong with the code?

Thanks!

Stacy
 
So after futzing with things after awhile it appears when I deleted some reports there were some object classes that somehow got created with those reports as well and those did not get deleted and I tried to remove them and couldn't.

At any rate I exported everything that was still working with no problems and imported into a new database and recreated the reports and so far everything is working with no problems including the code above.

So hopefully no more problems.

Thanks!

Stacy
 

Users who are viewing this thread

Back
Top Bottom