-
nothing happens
friends,
i have a table USERS with PEN number,PASSWORD string as fields. in my login screen when i till up and click login cmd-button nothing happens.
when i hit login it shold open DETAILS form.
the code for Login cmd button is given below:
Private Sub Command7_Click()
Dim uname As Long
Dim passwd As String
Form.Refresh
If Me!Text1 = "" And Me!Text2 = "" Then
Me.SetFocus
Me!Text1.SetFocus
Else
uname = Me!Text1
passwd = Me!Text2
If (uname = DLookup("[PEN]", "USERS", "[PEN]= " & Me!Text1.Value) And passwd = DLookup("[PASSWORD]", "USERS", "[PASSWORD]= '" & Me!Text2.Value & "'")) Then
DoCmd.OpenForm ("DETAILS")
Else
End If
End If
End Sub
-
better to give your controls meaningful names - is it called Command7? so is the code running?
and this code can be better written as
If DCount("*", "USERS", "[PEN]= " & Text1 & " AND [PASSWORD]= '" & Text2 & "'")=1 then
Also if PEN is not numeric, you need to include single quotes as you have for password
-
sure ajax. this is a crude one. i am making an original one with meaningful names. thanks for your suggestions.
-
a couple of suggestions:
If Me!Text1 = "" And Me!Text2 = ""
..... doesn't look correct to my eye and guessing it should be: If Me.Text1 = Me.Text2
it often is better to do the DCount of a query - and put the criteria in the query: rather than put the criteria in the DCount clause. This is because it is much easier to test. One can manually fire the query to see if it is working as one intends.
-
I'm guessing that
If Me!Text1 = "" And Me!Text2 = "" Then
is meant to check for the lack of data in those Controls...but it's actually only checking for Zero-Length Strings! 'Empty' Controls, in Access, are usually Null. To check for both ZLSs and Nulls, you can use a number of hacks, including
If Nz(Me!Text1, "") = "" And Nz(Me!Text2, "") = "" Then
And as Ajax said, the exact syntax depends on the Datatypes of Fields in the Where Clause.
Linq ;0)>
-
thanks for your valuable suggestions friends. i am new to this access programming. with little knowledge of programming i am trying to do a project of my own. actually i started it 1 month back. everytime i struck upon something and find it very difficult to find a way out. now i have u friends to help me. this project is done only on my interest in programming where i am still a student. hoping to get valuable advice from you experts. thanking you once again.
ramesh
-
Good luck to you rameshjctr. You've come to the right place with your questions. I've found people here to be quite helpful no matter what your skill level.
-
dear friends,
now the things are working fine for time being. hope it will continue. thanks a lot for your valuable helps. thanks everybody.
ramesh
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