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

Why do i get Type Mistmatch ?

P: 2
I have created a form for the user to enter password before accessing the system
The table password has been created with the field uname of type Text and pword of type Text. The uname is displayed as a combo box on the form. When I enter the password and click ok it says Type Mismatch (Error 13)

Here is the code:

Option Compare Database

Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize

uname.SetFocus
End Sub

Private Sub cmd_close_Click()
DoCmd.close
End Sub

Private Sub ok_Click()
Dim rcd As Recordset
Set dbs = CurrentDb
If (IsNull(uname) Or Len(Trim(uname)) = 0) Then
s = MsgBox("Please check that you have entered your username!")

Else
If (IsNull(pword) Or Len(Trim(pword)) = 0) Then
s = MsgBox("Please check that you have entered your password!")

Else
Set rcd = dbs.OpenRecordset("select pword from password where uname='" + Me.uname + "'")

If rcd!pword = Me.pword Then
DoCmd.close
DoCmd.OpenForm "mainmenu"
Else
DoCmd.Beep
bool = MsgBox("Invalid password! Try again please")
pword = " "
pword.SetFocus
End If
End If
End If
End Sub



Thnks for your help :)
Aug 14 '08 #1
Share this Question
Share on Google+
3 Replies


100+
P: 167
which Access version do you have?
In Access 2003 you can go to Tools->Security...
[HTML]Make password-protected database
Create .mdw file with users/user groups
Join the database to the .mdw file[/HTML]

This is probably far better than the solution you are trying to use.
Also it's possible to use .mdw file with Acc2007.

I suggest you try reading help on security, user and group accounts etc.
Aug 14 '08 #2

P: 2
which Access version do you have?
In Access 2003 you can go to Tools->Security...
[HTML]Make password-protected database
Create .mdw file with users/user groups
Join the database to the .mdw file[/HTML]

This is probably far better than the solution you are trying to use.
Also it's possible to use .mdw file with Acc2007.

I suggest you try reading help on security, user and group accounts etc.
Well..first of all thank you for your reply :)
i wanted to create that form as it shall have different users. Thus preventing some users to access some forms..
I dont think that the password wizard in access can help me out..
The database is in 2002 format
can you help?
Aug 14 '08 #3

missinglinq
Expert 2.5K+
P: 3,532
Set rcd = dbs.OpenRecordset("select pword from password where uname='" + Me.uname + "'")

I think Access is popping a Type Mismatch error because it sees you as trying to add your uname and quotation marks! You're using plus signs (+) for your concatenation, and you should be using the ampersand (&) sign instead.

Welcome to Bytes!

Linq ;0)>
Aug 14 '08 #4

Post your reply

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