Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Open Specific Form by User Login

I have a workbook that requires individuals to login to enter data. Once
they login, data is entered via a form. My question is how do I set the form
up so that only the users will see the form and not the manager? There are 4
worksheets, all visible for the manager only. The form puts the data into
one of the sheets. Any help would be great! Thanks!

This is what I have in the ThisWorkbook section:

Private Sub Workbook_Open()
LogOnForm.Show
EntryForm.Show
End Sub

This is the VB for the login form:

Private Sub cmdEXT_Click()
If MsgBox("Do you want to quit Excel", vbYesNo) = vbYes Then
Unload Me
Application.Quit
Else
Unload Me
Sheets("Logon").Activate

End If
End Sub

Private Sub cmdOK_Click()
Dim a, u, p, w(), i As Long, db As Worksheet, Flg As Boolean
Dim j As Long, x, y, c As Long, rSource As String
Set db = Sheets("DashBoard"): Flg = False: c = 0: x = 0
With db
a = .Range("a1").CurrentRegion
End With

u = UCase(Me.tbUN): p = Me.tbPW: Flg = False
With Application
x = .Match(u, .Index(a, 0, 1), 0)
End With

If Not IsError(x) Then
If Application.Index(a, x, 2) = p Then Flg = True
If Flg Then
ReDim w(1 To UBound(a, 2) - 2)
For j = 3 To UBound(a, 2)
If UCase(a(x, j)) = "A" Then c = c + 1: w(c) = a(1, j)
Next
Else
MsgBox "Incorrect Password", vbCritical + vbOKOnly
Exit Sub
End If
Else
MsgBox "Incorrect User Name", vbCritical + vbOKOnly
Exit Sub
End If

For i = 1 To Sheets.Count
If Sheets(i).Name < "Logon" Then
If IsError(Application.Match(Sheets(i).Name, w, 0)) Then
On Error Resume Next
Sheets(i).Visible = xlVeryHidden
Else
Sheets(i).Visible = xlSheetVisible
End If
End If
Next

Sheets("Logon").Visible = xlSheetVisible

EntryForm.Show

End Sub

Private Sub UserForm_Activate()
Me.tbPW.SetFocus
Me.tbUN.SetFocus
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Open Specific Form by User Login

You may be able to use
Environ("username")
to solve the problem - that will return the username who logged in. Set up
an If ... Then to test to see if it's the manager or nor and act accordingly.

"Bowtie63" wrote:

I have a workbook that requires individuals to login to enter data. Once
they login, data is entered via a form. My question is how do I set the form
up so that only the users will see the form and not the manager? There are 4
worksheets, all visible for the manager only. The form puts the data into
one of the sheets. Any help would be great! Thanks!

This is what I have in the ThisWorkbook section:

Private Sub Workbook_Open()
LogOnForm.Show
EntryForm.Show
End Sub

This is the VB for the login form:

Private Sub cmdEXT_Click()
If MsgBox("Do you want to quit Excel", vbYesNo) = vbYes Then
Unload Me
Application.Quit
Else
Unload Me
Sheets("Logon").Activate

End If
End Sub

Private Sub cmdOK_Click()
Dim a, u, p, w(), i As Long, db As Worksheet, Flg As Boolean
Dim j As Long, x, y, c As Long, rSource As String
Set db = Sheets("DashBoard"): Flg = False: c = 0: x = 0
With db
a = .Range("a1").CurrentRegion
End With

u = UCase(Me.tbUN): p = Me.tbPW: Flg = False
With Application
x = .Match(u, .Index(a, 0, 1), 0)
End With

If Not IsError(x) Then
If Application.Index(a, x, 2) = p Then Flg = True
If Flg Then
ReDim w(1 To UBound(a, 2) - 2)
For j = 3 To UBound(a, 2)
If UCase(a(x, j)) = "A" Then c = c + 1: w(c) = a(1, j)
Next
Else
MsgBox "Incorrect Password", vbCritical + vbOKOnly
Exit Sub
End If
Else
MsgBox "Incorrect User Name", vbCritical + vbOKOnly
Exit Sub
End If

For i = 1 To Sheets.Count
If Sheets(i).Name < "Logon" Then
If IsError(Application.Match(Sheets(i).Name, w, 0)) Then
On Error Resume Next
Sheets(i).Visible = xlVeryHidden
Else
Sheets(i).Visible = xlSheetVisible
End If
End If
Next

Sheets("Logon").Visible = xlSheetVisible

EntryForm.Show

End Sub

Private Sub UserForm_Activate()
Me.tbPW.SetFocus
Me.tbUN.SetFocus
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open a user form Pietro Excel Discussion (Misc queries) 1 August 29th 07 12:03 PM
Open form to specific record quits working Ron Weaver New Users to Excel 1 February 4th 07 07:48 PM
Trying to select a specific range based on the time value of user form input Jitranijam New Users to Excel 8 November 15th 06 12:52 AM
How do I automatically insert the user (login name) in Excel? ABlazer Excel Discussion (Misc queries) 1 September 19th 05 02:48 AM
use a button to open a user form? Hru48 Excel Discussion (Misc queries) 1 September 1st 05 07:41 PM


All times are GMT +1. The time now is 02:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"