visibility

bpaquette

Registered User.
Local time
Today, 15:42
Joined
Aug 13, 2003
Messages
119
With this syntax:

Private Sub cboGrade_Click(Cancel As Integer)
If Me!cboRank = "AMN" Or Me!cboRank = "AB" Or Me!cboRank = "A1C" Or Me!cboRank = "SRA" Or Me!cboRank = "SSGT" Or _
Me!cboRank = "TSGT" Or Me!cboRank = "MSGT" Or Me!cboRank = "SMSGT" Or Me!cboRank = "CMSGT" Then
Me!cboOfficerPAFSC.Visible = False
Me!cboOfficerPAFSCPrefix.Visible = False
Me!cboOfficerPAFSCSuffix.Visible = False
End Sub


i don't get any errors, but on the other hand it doesn't work :P


am i doing something wrong? basically its saying that if the rank is equal to one of 9 ranks, then the 3 cbo's listed should not show.
 
Firstly, the Click event does not have an argument therefore your inclusion of Cancel As Integer is somewhat confusing and should not be there.

Secondly, that's one mighty big OR scenario, try condensing it with a SELCT CASE statement:

Code:
Private Sub cboGrade_Click() 
    Select Case Me.cboRank
        Case Is = "AMN", "AB", "A1C", _
                        "SRA", "SSGT", "TSGT", _
                        "MSGT", "SMSGT", "CMSGT"
            Me.cboOfficerPAFSC.Visible = False 
            Me.cboOfficerPAFSCPrefix.Visible = False 
            Me.cboOfficerPAFSCSuffix.Visible = False
        Case Else
            ' I'm guessing you'd want to reset records here
            ' if the criterias specified have not been met
    End Select
End Sub

Also, are you sure you want this on the Click event and not on the AfterUpdate or Change event?

I also changed some of your code to early binding as opposed to late binding: ! to .
 
afterupdate would be fine except that it has to stick even when they're not changing values. basically i need to to recheck the if statement everytime a record is loaded, AND everytime the rank box is updated, so afterupdate would accomplish half the battle. i have it on click for testing purposes, and it has an arg because i accidentally selected the wrong event procedure and just filled in "Click" in replace of i dont remember what.

what is the difference between ! and . ?
 
bpaquette said:
what is the difference between ! and . ?

Here's a recent thread with the same question: :rolleyes:

click the smilie
 
thanks a load, miles. i should start looking for threads more often!
 
bpaquette said:
thanks a load, miles. i should start looking for threads more often!
I have a little work to do and Mile steps up to the plate and hits a homer...

I thought just to add if you want to do it "on load of a new record" you should call the after update event of the button from the On Current event of the form...

Regards
 

Users who are viewing this thread

Back
Top Bottom