Different Startup form for different users

brian0721

Registered User.
Local time
Today, 14:36
Joined
Dec 5, 2001
Messages
103
Is there a way that each person who logs in to the DB can each have a different start up form?

Thanks
 
If you're using OS such as Win2k or xp pro then you can use this function to determine the user id of the person logged in:

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
'Returns the network login name

On Error GoTo ErrorHandler

Dim lngLen As Long, lngX As Long
Dim StrUsername As String

StrUsername = String$(254, 0)

lngLen = 255

lngX = apiGetUserName(StrUsername, lngLen)

If lngX <> 0 Then
fOSUserName = Left$(StrUsername, lngLen - 1)
Else
fOSUserName = ""
End If

ExitProcedure:

Exit Function

ErrorHandler:

MsgBox Err.Number & ": " & Err.Description, vbOKOnly + vbExclamation

Resume ExitProcedure

End Function

Then you can create a table with everyone's ID and what form to open at startup.
 
using win98 with security and user levels set up. just trying to see if for instance "bob" signs on, i can make a form, specific to him open up?

possible?

thanks a ton!
 
If you're using access security then just create a table like I said at first with their access ID's. Then when the file opens have it look up the form in the table use CurrentUser(). Then run a docmd.openform with the formname in the table.
 
brian0721 said:
using win98 with security and user levels set up. just trying to see if for instance "bob" signs on, i can make a form, specific to him open up?

possible?

thanks a ton!
yes it is- i made a different message appear to each user when they logon.

have a User table that hold the attributes Username;Password;CustomFormName

create a query based upon this table and in the criteria for username/password use a parameter to obtain username/password

e.g forms!your logon form name e.g frmLogon!txtusername
forms!your logon form name e.g frmLogon!txtPassword

create a form based on this query and name it FrmLoginQry

now we are going to create another form that will run in the background and hold the current users information

Create an unbound form and name it FrmUserallocation. It sould contain the same text boxes as FrmloginQry

input the following code on click of logon


Code:
Private Sub cmdLogin_Click()

Dim X As String


DoCmd.OpenForm "FrmLoginQry", , , , , acHidden
DoCmd.OpenForm "FrmUserAllocation", acNormal, , , , acHidden


If Forms!FrmLoginQry!txtPassword <> "" Then
    
    DoCmd.Close acForm, "FrmLogon"
   
    ' the custom form details are copied from the opened query to the allocation form where it is used
    [Forms]![frmuserallocation]![CustomFormName] = [Forms]![FrmLoginQry]![CustomFormName]
    
   
    DoCmd.Close acForm, "FrmLoginQry"
    x= [Forms]![frmUserAllocation]![CustomFormName]

	DoCmd.OpenForm X
    
        Else
            

            DoCmd.Close acForm, "FrmLoginQry"
            DoCmd.OpenForm "Frmlogon"
            DoCmd.Close acForm, "FrmUserAllocation"
                
                  
End If

End Sub
 
That works good. When I click logon, a field pops up for username, then one for password. Only problem is, when you enter the password it shows the actual password, instead of ******. Any advice?

Thanks alot!
 
In the 'Input mask' property of the password textbox type 'Password'
 

Users who are viewing this thread

Back
Top Bottom