Loops to determine if button visible

jeff_i

Registered User.
Local time
Today, 02:33
Joined
Jan 24, 2003
Messages
50
I have the following code to determine if a button is visible:

Private Sub Form_Open(Cancel As Integer)
If fOSUserName() = "username" Then
Me.testdee.Visible = True
Else
Me.testdee.Visible = False
End If
End Sub

I have a table of users with yes/no check boxes for various buttons, I would like to run a query for the button then loop through this If statement to see if the user should be able to see this button. What I have tried seems to just put the whole thing into an endless loop

Thanks for any help or suggestions
 
Try this instead of a loop:

Private Sub Form_Open(Cancel As Integer)

Dim bln As Boolean
Dim strName As String

strName=fOSUserName()

bln=DLookUp("[checkbox field name]","[table name]","UserName=" & "'" & strName & "'")

If bln=True Then
Me.testdee.Visible=True
Else
Me.testdee.Visible=False
End if


I don't know how you've setup the checkbox whether it's checked you want them to see the button or not. Adjust accordingly.
 
Works Perfect

Rob

Thanks for your help this works perfectly for me

Jeff
 

Users who are viewing this thread

Back
Top Bottom