|
-
Jun 3rd, 2005, 06:58 AM
#1
Thread Starter
Member
[RESOLVED] Invalid Use of Null !
Hi All,
I am using following code written on a button click event on a user Login form in Access-2003 VBA.
Code -----------------------------------------------------
Private Sub cmdLogin_Click()
'Login procedure
Dim PasswordData As String
LoginName = txtUserName
Password = txtUserPass
PasswordData = DLookup("[UserPass]", "tbuser", "[UserName] = forms!Login!txtusername")
'PasswordData = DLookup("[UserPass]", "tbUser", "[UserName] = Login")
If Password = PasswordData Then
Call LoginFunction
Else
MsgBox "Sorry, your username or password was incorrect." & vbCrLf & vbCrLf & "Unable to login.", vbCritical, "Login Error"
End If
End Sub
-----------------------------------------Code
I have a table named tbUser and fields UserName, UserPass and UserPrev in this table. I want to get Passworddata where login Name match with any record in the table. When control comes to DLookup function an error Invalid Use of Null is raised. I can't guess what is the problem.
Anyone please help.
Alankar
Last edited by Alankar; Jun 20th, 2005 at 12:33 AM.
-
Jun 3rd, 2005, 07:18 AM
#2
Re: Invalid Use of Null !
On what line does this error occur?
-
Jun 3rd, 2005, 07:23 AM
#3
Re: Invalid Use of Null !
The error in itself means you're most likely pulling a null value out of your table.
This usually happens when I forget to tell it to stop at EOF.
Make sure its not trying to pull any null values from the table
-
Jun 3rd, 2005, 07:28 AM
#4
Thread Starter
Member
Re: Invalid Use of Null !
Hi Hack,
This error occurs where I call DLookup function. But I got the problem.
As kfcSmitty guessed it was trying to get some record which is not there actually.
Thanks
-
Jun 3rd, 2005, 08:05 AM
#5
Re: Invalid Use of Null !
 Originally Posted by Alankar
Hi Hack,
This error occurs where I call DLookup function. But I got the problem.
As kfcSmitty guessed it was trying to get some record which is not there actually.
Thanks
That is what I suspected as well, but I thought it was because a field contained Null data, not because a record was actually not there.
-
Jun 5th, 2005, 11:12 PM
#6
Thread Starter
Member
Re: Invalid Use of Null !
Hi Hack,
I have replaced the line as folloing to avoid this error. Now it is working fine.
----------------------Code-------------------
PasswordData = IIf(IsNull(DLookup("[tbUser]![UserPass]", "[tbuser]", "[tbUser]![UserName] = forms!Login!txtusername")), 0, DLookup("[tbUser]![UserPass]", "[tbuser]", "[tbUser]![UserName] = forms!Login!txtusername"))
----------------------Code---------------------
Thanks for help !
Alankar
Last edited by Alankar; Jun 8th, 2005 at 12:36 AM.
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
|
Click Here to Expand Forum to Full Width
|