On Current control.visible not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tetelestai
    New Member
    • Nov 2006
    • 34

    On Current control.visible not working

    I have a command button on a form that should be visible or not visible depending on a value in the current record and the current users user level. The code below is working as in the immediate window i get true and false when appropriate. However the command button will stay in its current state for several records. At times when I switch to the immediate window and back the button will do what it is supposed to do (ie be visible or hide). I tried the repaint method to force it but did not suceed.

    [CODE=vb]Private Sub Form_Current()
    If (CurrentUser.Ge tUserLevel <= 10 And Me.txtQStatusTy pe = 9) Or (CurrentUser.Ge tUserLevel <= 10 And Me.txtQStatusTy pe = 13) Then 'Admin
    Debug.Print "true"
    Me.cmdAward.Vis ible = True
    Me.Repaint
    Else
    Debug.Print "false"
    Me.cmdAward.Vis ible = False
    Me.Repaint
    End If
    End Sub[/CODE]
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    What version of Access are you runnnig? I can find, thru v2003, no reference to CurrentUser.Get UserLevel in VBA Help, reference books or on line. CurrentUser by itself, in VBA, returns a string that gives the name of the account that opened the db. You didn't, perchance, get this code from a Visual Basic source rather than a VBA source, did you?

    I also wonder if txtQStatusType is actually defined as a number? If it's defined in your table as Text datatype, you'd need quotation marks around the 9 and the 13.

    The only other thought would be corruption of some sort.

    Linq ;0)>

    Comment

    • Tetelestai
      New Member
      • Nov 2006
      • 34

      #3
      I'm running 2007.
      currentuser is a instance of a class i made, if you change due dates and such it records who you are and when you did it. I did not check that 'currentuser' was used elsewhere.
      QStatusType is defined as a number (long)

      Comment

      • Tetelestai
        New Member
        • Nov 2006
        • 34

        #4
        Could it have anything to do with when the information in the text box gets the current records information vs when the form's current event fires?

        Comment

        Working...