Log-in database problem username and password

juniepiper27

Registered User.
Local time
Today, 13:32
Joined
Sep 24, 2014
Messages
49
Dear Sir,

I have an error message or debug message in my code in username & password log in.. it has an error in if else statement

empname is a cobobox
empass is a txtbox
logempID is a autonum I.D
usrnmpass is a table name

there's an specific record in a table of usrnmpass showing in the attachment

this is my code....

Private Sub Command1_Click()
If IsNull(empname) Or empname = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
empname.SetFocus
Exit Sub
End If

If IsNull(empass) Or empass = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
empass.SetFocus
Exit Sub
End If

If empass.Value = DLookup("[empass]", "usrnmpass", "[logempID] = " & empname.Value) Then

logempID = empname.Value


DoCmd.Close acForm, "DATABASE LOG-IN", acSaveNo
DoCmd.OpenForm "EQUIPMENT DEPARTMENT MONITORING DATABASE"

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
empass.SetFocus
End If
End Sub

the error was in the if else statement above of DLookup function.. please give me the correct statement for Dlookup function..

Thanks & best regards,
 

Attachments

  • samplelog1.jpg
    samplelog1.jpg
    51.4 KB · Views: 103
  • samplelog2.jpg
    samplelog2.jpg
    46.2 KB · Views: 101
Sir,

I already found the site your recommend to me.. I try many things, remove the [] and remove the double quotes arrange my fields but still dubug the codes...

can you look at the if else statement..? in your opinion, the arrange is correct or no... only in the Dlookup function the code is debugging... if you help me to arrangement please try...

Thanks,
RODY
 
Did you compare the field name as I mention?
What you have in the table and what you use in the Dlookup?
 
ahh... Sir in the table the field name is..

LogempID - no caption I put
empname - the caption is "ENTER YOUR USERNAME"
empass - the caption is "ETNER YOUR PASSWORD"

I put the caption in the table properties that's why in the printscreen it showing the caption not the exactly fieldname.. but the fieldname in the above.. and the table name is usrnmpass.
 
Did you compare the field name as I mention?
What you have in the table and what you use in the Dlookup?


sir this is another printscreen for your reference therefore you can help me...

Please sir try to help me... thank you so much...

Thanks,
 

Attachments

  • debug code for username & password form.jpg
    debug code for username & password form.jpg
    80.7 KB · Views: 104
  • debug code for username & password form2.jpg
    debug code for username & password form2.jpg
    55.2 KB · Views: 108
  • debug code for username & password table.jpg
    debug code for username & password table.jpg
    45.9 KB · Views: 103
First, I would stop using .value throughout -

so this

If empass.Value = DLookup("[empass]", "usrnmpass", "[logempID] = " & empname.Value) Then

becomes
If empass = DLookup("[empass]", "usrnmpass", "[logempID] = " & empname) Then


however, I think there are some general errors that are affecting your function, both syntax and practical.

if empname is text then this syntax is correct

If empass = DLookup("[empass]", "usrnmpass", "[logempID] = " & chr(34) & empname & chr(34)) Then

furthermore, if no user is found, this will return null so this final adjustment is probably also required

If empass = nz(DLookup("[empass]", "usrnmpass", "[logempID] = " & chr(34) & empname & chr(34)),"") Then

hope this helps
 
First, I would stop using .value throughout -

so this

If empass.Value = DLookup("[empass]", "usrnmpass", "[logempID] = " & empname.Value) Then

becomes
If empass = DLookup("[empass]", "usrnmpass", "[logempID] = " & empname) Then


however, I think there are some general errors that are affecting your function, both syntax and practical.

if empname is text then this syntax is correct

If empass = DLookup("[empass]", "usrnmpass", "[logempID] = " & chr(34) & empname & chr(34)) Then

furthermore, if no user is found, this will return null so this final adjustment is probably also required

If empass = nz(DLookup("[empass]", "usrnmpass", "[logempID] = " & chr(34) & empname & chr(34)),"") Then

hope this helps



thank you for your response... but still an error mentioning "Run-time error '3464' - Data type mismatch in criteria expression" please find attached printscreen for your reference.

please help me.. thank you so much....


here's another printscreen with highlight debug...
 

Attachments

  • error again3.jpg
    error again3.jpg
    89.1 KB · Views: 87
  • error again4.jpg
    error again4.jpg
    89.9 KB · Views: 92
  • error again1.jpg
    error again1.jpg
    91.2 KB · Views: 104
  • error again2.jpg
    error again2.jpg
    89.5 KB · Views: 105
Last edited:
well if empname is numeric, then it needs this

If empass = nz(DLookup("[empass]", "usrnmpass", "[logempID] = " & empname),"") Then

you are testing logempid, which sounds like it is a numeric field, with empname which sounds like it is text. maybe that is the mismatch. That would produce an error of that nature
 
well if empname is numeric, then it needs this

If empass = nz(DLookup("[empass]", "usrnmpass", "[logempID] = " & empname),"") Then

you are testing logempid, which sounds like it is a numeric field, with empname which sounds like it is text. maybe that is the mismatch. That would produce an error of that nature


the emlogID is a Auto Number
empname is a text which is a combobox
empass is also a text..
 
Do you have the SQL string for the combobox like below and did you remember to set the column width's property to: 0cm;1cm?
Code:
SELECT [emplogID], [empname] FROM usrnmpass;
 
Do you have the SQL string for the combobox like below and did you remember to set the column width's property to: 0cm;1cm?
Code:
SELECT [emplogID], [empname] FROM usrnmpass;
[/QU

where I will put the above command SELECT [emplogID], [empname] FROM usrnmpass;[/CODE][/QU could you please tell me becoz I'm only a beginner developer of databases..

Thank you...
 
In the rowsource for the combobox, (what do you have?).
If you can't get it, post your database.
 
In the rowsource for the combobox, (what do you have?).
If you can't get it, post your database.


Ok sir,, I get now and its working Properly now... check the attachment and its working properly now... but I have another question.. I want in the form load the txtempass will not showing the password automatically.. becoz when the form load its showing the password. and also one more.. I want to show a Msgbox after I enter the login command button and showing the form there's a Msgbox stating "Welcome "empname"

can you give me the code for my last two question

thanks you so much and more power
 

Attachments

  • LOGIN FORM.jpg
    LOGIN FORM.jpg
    48.8 KB · Views: 99
  • COMBO PROPERTIIES.jpg
    COMBO PROPERTIIES.jpg
    103.2 KB · Views: 78
  • successful codes.jpg
    successful codes.jpg
    92.7 KB · Views: 91
.. I want in the form load the txtempass will not showing the password automatically
Then make the it unbound.
. I want to show a Msgbox after I enter the login command button and showing the form there's a Msgbox stating "Welcome "empname"
Then put the Msgbox in your code after you've checked that both user and password are correct!

If an answer help you, why not press the "Thanks" button?
 
Then make the it unbound.

Then put the Msgbox in your code after you've checked that both user and password are correct!

If an answer help you, why not press the "Thanks" button?



Sir,

there's a big error.... I put an unbound textbox to be get the value of empass to emplogID and empname and it will become BIG ERROR... please see the attached pictures screenshots. after I follow what you said the SQL COMMANDS it will become big error..


please help me.... waaaaaaa :( :'(
 

Attachments

  • big error1.jpg
    big error1.jpg
    95.9 KB · Views: 69
  • big error2.jpg
    big error2.jpg
    92.8 KB · Views: 63
  • SQL VIEW.jpg
    SQL VIEW.jpg
    87.3 KB · Views: 70
Post your database!

I attached my database... please try to help me in the log-in file... its almost Ok but the problem the first username are change to number 1, 2 3 & 4... I will become crazy for this.... :( :'(

Please Sir, I'm begging for your help.....
 

Attachments

and also sir, please help in my thread before that I want in the combo box showing if there's no record, there's a msgbox will appear no record found.. please sir.. fix that for me... in the form sir, in the label FIND RECORD. and combobox for search.... I want that if there's no record found it will show the messagebox that "no record found in your search"

hoping for your help to fix my database... Thank you so much....
 

Users who are viewing this thread

Back
Top Bottom