checking user names and then actioning

  • Thread starter Thread starter msdnnews
  • Start date Start date
M

msdnnews

can some one help me with this bit of code (im a beginner) im trying to
determin wether certain users (admins) are logged on if not then disable
some command buttons (im using a secured.mdw file) ive tried useing
different combinations but no luck!!!!!

(from my switchboard)
Private Sub Form_Open()
'check to see if the user is an administrator
If CurrentUser() Is "admin" Or "john" Or "craig" Then

'if not disable admin features
Forms!frmForm!Command37.Enabled = False
Forms!frmForm!Command32.Enabled = False

Else

Forms!frmForm!Command37.Enabled = True
Forms!frmForm!Command32.Enabled = True


End Sub
 
Already answered in another group to which you posted the same question.

If you feel you need to post to more than one group (HINT: it's seldom
necessary), please have the courtesy to cross-post (send the one message to
all groups at once), rather than multi-post (send individual messages to
each group). In this way, all responses to your post will be available
together, regardless of what group the responder was in, and the rest of us
won't have to read your post multiple times. (It also uses fewer server
resources)

I see you're using Outlook Express. Click the "Newsgroups:" label to the
left of the box containing the name of the current newsgroup. That will open
a dialog that will let you add additional newsgroups to your post. Note that
it's generally consider to be A Bad Thing to cross-post to more than about 2
or 3 newsgroups. (In fact, at
http://www.microsoft.com/presspass/features/2001/Mar01/Mar27pmvp.asp
Microsoft suggests that "One group will suffice")
 
-----Original Message-----

can some one help me with this bit of code (im a beginner) im trying to
determin wether certain users (admins) are logged on if not then disable
some command buttons (im using a secured.mdw file) ive tried useing
different combinations but no luck!!!!!

(from my switchboard)
Private Sub Form_Open()
'check to see if the user is an administrator
If CurrentUser() Is "admin" Or "john" Or "craig" Then

'if not disable admin features
Forms!frmForm!Command37.Enabled = False
Forms!frmForm!Command32.Enabled = False

Else

Forms!frmForm!Command37.Enabled = True
Forms!frmForm!Command32.Enabled = True


End Sub


.
This code may help you. Found it on the Microsoft site.
Only issue may be that it is an ADO implementation. I
program mainly using ADO instead of DAO.

Sub ShowUserRosterMultipleUsers()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long

Set cn = CurrentProject.Connection

' The user roster is exposed as a provider-specific
schema rowset
' in the Jet 4.0 OLE DB provider. You have to use a
GUID to
' reference the schema, as provider-specific schemas
are not
' listed in ADO's type library for schema rowsets

Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

'Output the list of all users in the current database.

Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
"", rs.Fields(2).Name, rs.Fields(3).Name

While Not rs.EOF
Debug.Print rs.Fields(0), rs.Fields(1), _
rs.Fields(2), rs.Fields(3)
rs.MoveNext
Wend

End Sub

Hope this helps

John ;-)
 
Back
Top