 |
 |

02-22-2003, 06:58 AM
|
|
|
Problem with adding new users to database... Please Help
|
I have encountered a problem with a project i'm doing, the solution is probably quite simple, but I've only been using VB for a few weeks and only know a few basic commands / functions.
I am using Excel 2000, with VB v6.0, here is what I'm trying to do...
I have a user database created through a dataform, and I have a Userform which people in the database can use to log in from, this includes entering a username and password...
However, I want a new user (someone who is not in the database) to be able to enter their details and have an account created for them...
Also when they finish entering the details they will click a button to verify it, I want this button to copy their details into the dataform (I think I can already do this), but more importantly to copy their username and password into the same VB subroutines as the current members have theirs stored... And then to save the file to keep the new details...
So far I have been unable to record a macro to go into VB and just type in these details, it didn't seem to work... But I would have thought their is some command I can write manually for the macro button to edit these subroutines with the new info when clicked on...
If you need to see my current code for the Userform where the usernames and passwords are checked, here is the code:
Code:
Private Sub EnterID_Click()
'THIS WORKS NOW, DO NOT CHANGE!
If UserID = "121" Then
PasswordButton.Enabled = True
Password.Enabled = True
EnterPassword.Enabled = True
Proceed.Enabled = False
Password = ""
ElseIf UserID = "122" Then
PasswordButton.Enabled = True
Password.Enabled = True
EnterPassword.Enabled = True
Proceed.Enabled = False
Password = ""
ElseIf UserID = "123" Then
PasswordButton.Enabled = True
Password.Enabled = True
EnterPassword.Enabled = True
Proceed.Enabled = False
Password = ""
ElseIf UserID = "124" Then
PasswordButton.Enabled = True
Password.Enabled = True
EnterPassword.Enabled = True
Proceed.Enabled = False
Password = ""
ElseIf UserID = "125" Then
PasswordButton.Enabled = True
Password.Enabled = True
EnterPassword.Enabled = True
Proceed.Enabled = False
Password = ""
Else: PasswordButton.Enabled = False
Password.Enabled = False
EnterPassword.Enabled = False
Proceed.Enabled = False
Password = ""
UserID = ""
MsgBox "The User ID you have entered has not been found, please re-enter your User ID.", vbOKOnly, "User ID not found"
End If
'THIS WORKS NOW, DO NOT CHANGE!
End Sub
Private Sub EnterPassword_Click()
'THIS WORKS NOW, DO NOT CHANGE!
Proceed.Enabled = False
If UserID = "121" Then
If Password = "pass1" Then
Proceed.Enabled = True
Else: MsgBox "The Password you have entered is incorrect, please re-enter your password.", vbOKOnly, "Password Incorrect"
Password = ""
End If
End If
If UserID = "122" Then
If Password = "pass2" Then
Proceed.Enabled = True
Else: MsgBox "The Password you have entered is incorrect, please re-enter your password.", vbOKOnly, "Password Incorrect"
Password = ""
End If
End If
If UserID = "123" Then
If Password = "pass3" Then
Proceed.Enabled = True
Else: MsgBox "The Password you have entered is incorrect, please re-enter your password.", vbOKOnly, "Password Incorrect"
Password = ""
End If
End If
If UserID = "124" Then
If Password = "pass4" Then
Proceed.Enabled = True
Else: MsgBox "The Password you have entered is incorrect, please re-enter your password.", vbOKOnly, "Password Incorrect"
Password = ""
End If
End If
If UserID = "125" Then
If Password = "pass5" Then
Proceed.Enabled = True
Else: MsgBox "The Password you have entered is incorrect, please re-enter your password.", vbOKOnly, "Password Incorrect"
Password = ""
End If
End If
'THIS WORKS NOW, DO NOT CHANGE!
End Sub
If this has made my problem more confusing, then I basically want to create a button with a macro to add extra UserIDs and Passwords, and then save the file...
I hoped I have explained this well enough, and I hope I can get some positive ideas and feedback. Thanks alot if you have bothered to read this far, I would greatly appreciate ANY help which could be offered.
|
|

02-22-2003, 07:22 AM
|
 |
Green-Eyed
Super Moderator * Guru *
|
|
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
|
|
|
Hard-coding passwords and other user-info is the wrong way to go.
I'm afraid you will have to change the bits that read 'THIS WORKS NOW, DO NOT CHANGE!
You should maintain a hidden worksheet or some other updatable media for your login info...
|
|

02-22-2003, 07:59 AM
|
|
|
Hmmmm, that really doesn't help me much, I first considered using a hidden sheets, but I couldn't think of a way to link the text boxes on my Userform to the info in the sheet...
Any ideas on how I could check the info the user types in against the data on a the hidden sheet, and allow them to either log in correctly or get an error message come up if they've entered incorrect details?
The 'THIS WORKS NOW, DO NOT CHANGE! part was simply there to remind me not to make any changes to the basic structure of it, so I wouldn't accdientally mess it up...
Thanks for your help, I really appreciate it, I pretty much a total newbie with this, and I'm new on the boards, so thanks a lot.
If anyone else has any comments or suggestions, please feel free to offer your knowledge 
|
|

03-20-2003, 01:39 AM
|
 |
Junior Contributor
|
|
Join Date: Dec 2002
Posts: 213
|
|
|
you think you're a total newbie? lol, i am more than you. lol
hmm, anyway.. i wouldnt have a clue, sorry i cant help man. Ill think about it, as this is what im going to start to make soon. So ill get back to you.
|
__________________
VbNewb23
Current Project: RPG...
Last Project: Map Editor
|

04-10-2003, 01:10 AM
|
|
Newcomer
|
|
Join Date: Apr 2003
Posts: 6
|
|
|
You should have 2 listboxes. Using 1 listbox to contain the User ID data and another contain all the Password data.
You may use this codes:
validData = False
i=0
do while i<=lstID.ListCount-1
If ID.Text = lstID.List(i) And Password.Text = lstPassword.List(i) Then
ValidData = True
Exit Do
Else
i=i+1
End If
loop
If ValidData = False Then
msgbox "User ID not exist or wrong password or both", , "Error"
End If
I suggest you to use Microsoft Access to store data, simple and easy to use...
Create a Access table with 2 columns namely ID and Password. You need not have Primary key.
After that, at your form or open a login form, create a data control.
Change the following porperties:
name: dat
databaseName: (Locate Your database)
recordsource: (name of your table)
Visible: false
Create 2 textbox namely dBID and dBPassword
for both textbox, change visible to false
Create 1 command button and change the following properties:
name: cmdLoad
Visible: False
(I assume that you need to click a button before this login form pops up)
Double click on the OK button and type the following codes:
Found = False
dat.Refresh
Do until dat.Recordset.EOF
If txtUserName.Text = dBID.Text And txtPassword.Text = dBPassword.Text Then
Found = True
Exit Do
Else
dat.Recordset.MoveNext
End If
loop
If Found = False then
msgbox "Either user ID or Password or both are not existed."
End If
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|