Hiding a field on a form

ekta

Registered User.
Local time
Today, 13:10
Joined
Sep 6, 2002
Messages
160
I use the code below to lock and hide some of the fields on my form depending on the userid and userlevel. It works fine but the problem is that when the user opens this form I want to hide
the hide the field username. When the user opens the form it is visible and after navigating through 6-7 records it becomes invisible automatically. I want it to be hidden as soon as the form opens. I don't know why it does that???


Private Sub Form_Current()
'Build SQL String from creating recordset to determine if
'the current record is from the current user
SQL = "SELECT UserName, UserLevel FROM tblBusinessOppurtunity_Main " & _
"INNER JOIN N_tblLocalUser ON tblBusinessOppurtunity_Main.UserName = N_tblLocalUser.UID " & _
"WHERE (Opportunity_ID = " & Me.Opportunity_ID & " AND UserName = '" & LocalUser & "')" '& _
"OR USERLEVEL = 'Admin'"

objRec.Open SQL, CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic, adCmdText

'If there is a match, allow the user to add, delete and edit records
If objRec.RecordCount = 1 Then
Me!UserName.Visible = False
Me.AllowAdditions = False
Me.AllowDeletions = True
Me.AllowEdits = True
Me!Combo48.Locked = True
Me!Business_Lead.Locked = True
'Else don't allow the user to add, delete and edit records
Else
Me.AllowAdditions = False
Me.AllowDeletions = False
Me.AllowEdits = False
End If
objRec.Close
End Sub

Thanx
Ekta
 
Set the Visible property of the field itself to False. Then it won't ever display.
 
Hi Elana:

If you look at the code that's what I have done.
Me!UserName.Visible = False
But the problem is that when you open the form it appears but after navigating theough 7-8 records it become invisible.

Ekta
 
I know you set it in code, but have you set it in the actual field's visible property?
 

Users who are viewing this thread

Back
Top Bottom