Compile error - Method or data member not found

Scythed

Registered User.
Local time
Yesterday, 19:23
Joined
Aug 30, 2008
Messages
28
I am trying to use this script to act as a security feature so that you have to login, but it is giving me a Compile error - Method or data member not found. If anyone knows what the problem is I would really appreciate it. Thank you.

Private Sub Login_Click()
Dim strUser As String
Dim strPWD As String
Dim intUSL As Integer

strUser = Me.UserID
If DCount("[Password]", "[Employee Details]", "[UserID]=" & Me.UserID) > 0 Then
strPWD = DLookup("[Password]", "[Employee Details]", "[UserID]=" & Me.UserID)
If strPWD = Me.Password Then
DoCmd.OpenForm "Browse Menu"
Else
MsgBox "Please try again" & vbCrLf & vbLf & "You have entered the incorrect password.", vbCritical, "Invalid Password"
Exit Sub
End If
End If
End Sub
 
You can simplify this by using the following:

Code:
Dim Rs As DAO.Recordset
Dim bFlag As Boolean

Set Rs = CurrentDb.OpenRecordset("Select * From [Employee Details] Where UserID = " & Me.UserID)

If Not Rs.EOF Or Not Rs.BOF Then
   bFlag = True
   Rs.Close
End If

Set Rs = Nothing

If bFlag = True Then
    DoCmd.OpenForm "Browse Menu"
Else
    MsgBox "Please try again" & vbCrLf & vbCrLf & "You have entered the incorrect password.", vbCritical, "Invalid Password"
End If

Using this method you are only performing one enquiry and should you need to refer to other items in the Employee Details table you can refer to them whilst the record set is open.

Bear in mind you are only asking for a password only. There is no validation as to who is using this password. How do you know that the person using the password has access to the browse menu? If security is an issue you should be asking for theior user name and password, then you can validate both items.

CodeMaster::cool:
 
What line does it error on? If you're looking for UserID on the popup signin form did you bring it over from somewhere or is the user entering it?
 
Thank you very much for your help I figured it out stupid me I forgot to rename the user input :P
DCrake security really isnt an issue for me because its just a school assignment. Security is just a little bonus in marks, not a ground breaking thing in terms of being beaten etc.

Do any of you guys know how to make it so if i type the wrong username it pops up a little error message? As it is if i type the wrong password but the right username it tells me that I have entered the wrong details, is there any way for it to check username as well? I am not sure if that is what u meant Dcrake lol I didn't really understand your code very well sorry this is really my first couple of days working with VBA. Thank you.
 
You can just run a simple lookup routine on the user name just like you did on the password. Or sometimes I do a combo box with the user names already in it and just let them pick their name...
 
You mentioned a AWF reserved word or phrase in your last post "School Assignment". Many members, myself included, tend to shy away from these questions as we all had to learn somewhere. Climbing on the backs of giants to gain additional prestige is frowned upon, by me anyway.

CodeMaster::cool:
 
Yeah I would have learnt this for myself but our teacher has barely even taught us how to do sql queries properly, he is more of the type to sit back and say have at it. Which is fine except I need a little bit of guidance at least to do stuff in something like VBA. Also this is for high school, just making sure you don't think I am doing it for University or anything :P.
 
Ah... Simple questions when doing school work is fine. DCrake is referring to some people who log in and try to get us to do their entire school project for them -
 
Ken,

One question leads to another, and another, and another....

My solution was designed to encompass the anticipated next question. However if the poster cannot grasp the concept of the origninal answer then how are we to proceed.

David
 
I think you planted the 'DAO Recordset' method seed and IMHO Scythed will probably put forth the effort to learn it (Which will probably make him better with VBA than the instructor :))

I don't however think which should be on the look-out for 'students' and write them off carte blanc. Only the ones that act sneaky and expect us to write an entire app for them. Scythed's question seemed a simple 'I tried this can somebody tell me why it didn't work' question.

Just my 2 cents :)
 
Thank you both very much for your help I did some tweaking and messing around and I think I have it working :)
 

Users who are viewing this thread

Back
Top Bottom