By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,856 Members | 1,967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,856 IT Pros & Developers. It's quick & easy.

On Current control.visible not working

P: 34
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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     If (CurrentUser.GetUserLevel <= 10 And Me.txtQStatusType = 9) Or (CurrentUser.GetUserLevel <= 10 And Me.txtQStatusType = 13) Then 'Admin
  3.         Debug.Print "true"
  4.         Me.cmdAward.Visible = True
  5.         Me.Repaint
  6.     Else
  7.         Debug.Print "false"
  8.         Me.cmdAward.Visible = False
  9.         Me.Repaint
  10.     End If
  11. End Sub
Mar 24 '08 #1
Share this Question
Share on Google+
3 Replies


missinglinq
Expert 2.5K+
P: 3,532
What version of Access are you runnnig? I can find, thru v2003, no reference to CurrentUser.GetUserLevel 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)>
Mar 25 '08 #2

P: 34
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)
Mar 25 '08 #3

P: 34
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?
Mar 25 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.