-
Creating a Login Form
Hi,
I am wanting to create a login form for a system I am creating.
- The login form must open before anything else and all of the other sheets must not be accessible until the user has logged in.
- The user must be able to create a username and password which will be saved into another sheet. The macro must check to see if that username or password has already been taken.
- The user must be able to login using a previously created account.
I don't even know where to start as I have only been doing this for a couple of weeks.
Thanks
Jord
-
Here is my code so far, I am getting a type mismatch on the line in yellow and I have no idea what that even means.
Sub LogIn()
Application.ScreenUpdating = False
Dim uname, pword As String
Dim RowNum, usercount, rowcount As Integer
Dim error As Boolean
Sheets("Login").Select
uname = Range("Username")
pword = Range("Password")
RowNum = Range("NumUsers")
If uname <> "" And pword <> "" Then
usercount = 1
rowcount = 1
Sheets("Username and Password").Select
Do While usercount <= RowNum
If uname = Range("A" & rowcount) And pword = Range("B" & rowcount) Then
Sheets("Login").Select
Range("Username") = ""
Range("Password") = ""
Sheets("MainMenu").Select
Exit Sub
Else
error = True
usercount = usercount + 1
rowcount = rowcount + 1
End If
Loop
If error = True Then
Sheets("Login").Select
Range("Username") = ""
Range("Password") = ""
MsgBox " Please try again, You must enter a valid username and password", vbOKOnly
End If
Else
MsgBox "You must enter both a username and password"
End If
End Sub
-
Hi Jord
You might like to have a look at this thread, there is a routine in there i created for saving users & passwords. Can always be modified to suit.
Rob
http://www.vbaexpress.com/forum/showthread.php?t=36558
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules