form visible dependant on value (1 Viewer)

Blackwidow

Registered User.
Local time
Today, 13:56
Joined
Apr 30, 2003
Messages
149
Can anyone see what I've done wrong here? I cant get it to work and been over it a thousand times :(

If ([Present%] >= 97) Then
FrmWiseUpGold.Visible = True
FrmWiseUpBronze.Visible = False
FrmWiseUpRed.Visible = False
FrmWiseUpPurple.Visible = False
FrmWiseUpSilver.Visible = False
Else
If ([Present%] >= 95 <= 96) Then
FrmWiseUpSilver.Visible = True
FrmWiseUpBronze.Visible = False
FrmWiseUpGold.Visible = False
FrmWiseUpRed.Visible = False
FrmWiseUpPurple.Visible = False
Else
If ([Present%] >= 90 <= 94) Then
FrmWiseUpBronze.Visible = True
FrmWiseUpGold.Visible = False
FrmWiseUpSilver.Visible = False
FrmWiseUpRed.Visible = False
FrmWiseUpPurple.Visible = False
Else
If ([Present%] >= 80 <= 89) Then
FrmWiseUpRed.Visible = True
FrmWiseUpSilver.Visible = False
FrmWiseUpBronze.Visible = False
FrmWiseUpGold.Visible = False
FrmWiseUpPurple.Visible = False
 

Summerwind

Registered User.
Local time
Today, 05:56
Joined
Aug 25, 2005
Messages
91
Might be showing some ignorance but I'd be surprised if that compiled as I don't see an EndIf statement.

I would suggest that this is a classic case for the need of a SELECT CASE clause. It would be neater and definitely quicker.
 

KenHigg

Registered User
Local time
Today, 08:56
Joined
Jun 9, 2004
Messages
13,327
To start with, here is a little cleaner way to code this:

Code:
Select Case me![Present%]
    Case > 96
        FrmWiseUpGold.Visible = True
        FrmWiseUpBronze.Visible = False
        FrmWiseUpRed.Visible = False
        FrmWiseUpPurple.Visible = False
        FrmWiseUpSilver.Visible = False
    Case > 94
        FrmWiseUpSilver.Visible = True
        FrmWiseUpBronze.Visible = False
        FrmWiseUpGold.Visible = False
        FrmWiseUpRed.Visible = False
        FrmWiseUpPurple.Visible = False
    Case > 89
        FrmWiseUpBronze.Visible = True
        FrmWiseUpGold.Visible = False
        FrmWiseUpSilver.Visible = False
        FrmWiseUpRed.Visible = False
        FrmWiseUpPurple.Visible = False
     Case > 79
        FrmWiseUpRed.Visible = True
        FrmWiseUpSilver.Visible = False
        FrmWiseUpBronze.Visible = False
        FrmWiseUpGold.Visible = False
        FrmWiseUpPurple.Visible = False
End Select

The only problem I can see is if you allow nulls or you may have text -> number problems...

(And lose the '%' char when naming objects!)
 

Blackwidow

Registered User.
Local time
Today, 13:56
Joined
Apr 30, 2003
Messages
149
sorry did have my end ifs after

I've tried doing it the way you suggested but as I've never used it before not sure if I am putting it in the right place? I have placed it in Current(). But nothing is coming up.

I didnt quite undertand the (And lose the '%' char when naming objects!)? the field is a percentage field.

much confused sorry!
 

KenHigg

Registered User
Local time
Today, 08:56
Joined
Jun 9, 2004
Messages
13,327
Is Present% the name of a textbox on the form? Or maybe the name of a field in the table?
 

Blackwidow

Registered User.
Local time
Today, 13:56
Joined
Apr 30, 2003
Messages
149
Its the name of the field in the underlying table, but yes it is also on the form
 

KenHigg

Registered User
Local time
Today, 08:56
Joined
Jun 9, 2004
Messages
13,327
Look in the table and see if any of the records are blank. Also, I assume this is a number data type field..?
 

Blackwidow

Registered User.
Local time
Today, 13:56
Joined
Apr 30, 2003
Messages
149
I havent got any blank records all of them have values. And it is a number field. Field size double, format percent..

Should I have put your code in the on current event property?
 

KenHigg

Registered User
Local time
Today, 08:56
Joined
Jun 9, 2004
Messages
13,327
Hum... Maybe you should have gone with test values something like .97 instead of 97...?
 

mcirvine

Registered User.
Local time
Today, 14:56
Joined
Dec 13, 2005
Messages
30
Indeed if you have field format on percent you need to use the right format. Right now you are checking if the percent is > 9700%. Think its 0,97 you need to use in the case statement
 

Blackwidow

Registered User.
Local time
Today, 13:56
Joined
Apr 30, 2003
Messages
149
Yay!

Thanks everyone for all your help, the problem was that it needed to be 0.97 etc and not using the whole numbers!

I should have got that one! Brain freeze
 

Users who are viewing this thread

Top Bottom