By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,478 Members | 1,585 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,478 IT Pros & Developers. It's quick & easy.

Creating Access cmdButton to Compare Data with VBScript

P: 1
I pose a question as a newbie here -

I have been trying to do the following : I created a form that is set to start-up first. I know that microsoft security is better for security and I won't be using it anyway. I have the person type into 2 list boxes their username and password, and then want it to compare to a table named UserList. I have tried a couple different ways to compare the data, but the way I think I should do it is as such.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdLogin2_Click()
  2. On Error GoTo Err_cmdLogin2_Click
  3.  
  4.     Dim stUserName1, stusername2, stpassword1, stPassword2, As String
  5.  
  6.  
  7.     Set stUserName1 = me.lstUserID
  8.     Set stusername2 = me.lstPassword
  9.     Set stpassword1 = tables.userlist("Password")
  10.     Set stPassword2 = tables.userenter("Password")
  11.  
  12.     IIf ((stUserName1 = stusername2) = True), (Open Form "Sample"), (MsgBox("Incorrect UserName or Password!", Open Form "Login")
  13.  
  14. Exit_cmdLogin2_Click:
  15.     Exit Sub
  16.  
  17. Err_cmdLogin2_Click:
  18.     MsgBox Err.Description
  19.     Resume Exit_cmdLogin2_Click
  20.  
  21. End Sub
I know there are many errors in that code and some of it I just type in right now to get the idea of what I am trying to do. Any help would be appreciated!
Oct 9 '08 #1
Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,709
Check out this recent thread (Restrict multiple logins with single username at sametime in ms access). It should help you.

Welcome to Bytes!
Oct 9 '08 #2

ADezii
Expert 5K+
P: 8,679
No matter how you implement your logic, Passwords should always be an 'exact' match (case sensitive), as least in my humble opinion. One way to check for an exact match is with the StrComp() Function. I'll post a simple example below for you to review:
Expand|Select|Wrap|Line Numbers
  1. Dim strOne As String
  2. Dim strTwo As String
  3. Const conEXACT_MATCH As Byte = 0
  4.  
  5. strOne = "Antelope"
  6. strTwo = "antelope"
  7.  
  8. If StrComp(strOne, strTwo, vbBinaryCompare) = conEXACT_MATCH Then
  9.   Debug.Print "Exact Match!"
  10. Else
  11.   Debug.Print "Not an Exact Match!"
  12. End If
OUTPUT
Expand|Select|Wrap|Line Numbers
  1. Not an Exact Match!
Oct 9 '08 #3

NeoPa
Expert Mod 15k+
P: 31,709
In my opinion too. And I'm never humble :D
Oct 10 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.