Ask Experts Questions for FREE Help !
Ask
    informatika-ek's Avatar
    informatika-ek Posts: 1, Reputation: 1
    New Member
     
    #1

    Jul 7, 2011, 01:15 PM
    visual basic coding in access 2007
    HI!
    I am a student and I am preparing my BECHALOR thesis. I am constructing and manipulating a library database. My problem is this:
    I've a table named tblUsers that have this fields:
    UserName—–Text
    Password——Text
    Access——–Number(1 for student and o for admin)
    ID—————-Autonumber
    I've also created a login form witch contain a combo box named Combo21 that displays all the UserNames , a textbox named Password and a button named Login.
    That I want my code to do is to control
    1- if the username is entered
    2- if the password is entered
    3- to control if the password entered match with the username and only if this condition is true to open Form Student_Menu if the [Access].[tblUsers]=1 or open Form Admin_Menu if the [Access].[tblUsers]=0.
    My problem is with the VBA syntax or smth else because I have a clear idea of what to do but I can't express it in VBA code.
    Hope that my explanation was understandable!! I would appreciate any replies.Thanks in avance!!
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #2

    Jul 7, 2011, 06:29 PM

    Thanks for posting here, but I meant for you to post the code you are using.

    Again, you need to define for me what is not working. You need to explain what is is you do and what happens when you do it. Without that I can't help you. And when I ask specific questions, make sure you answer them.

    What you might try is zipping up a copy of your database and attaching to a post here.
    Micromax's Avatar
    Micromax Posts: 22, Reputation: 1
    New Member
     
    #3

    Jul 8, 2011, 02:40 PM
    Hi,

    I will assume you have the passwords and user names in the same table.

    I believe the code may go something like this.

    Private Sub cmd21_Click
    If txtPassword.Text = "mypassword" Then
    Beep
    Beep
    lblPromp.Caption = "Succesful Login" 'If you want the user to know
    Else
    lblPrompt.Caption = "Wrong Password-Try Again"
    txtPassword.Text = "" 'Erase the Password attempt
    txtPassword.SetFocus 'Put the focus back on the text box
    End If
    End Sub

    I hope this helps,

    Rob




    Micromax's Avatar
    Micromax Posts: 22, Reputation: 1
    New Member
     
    #4

    Jul 8, 2011, 02:43 PM
    Comment on Micromax's post
    Should be lblPromp.Caption
    I couldn't find a edit answer button.
    I noticed I made a typo. Sorry.
    Rob
    Micromax's Avatar
    Micromax Posts: 22, Reputation: 1
    New Member
     
    #5

    Jul 8, 2011, 04:13 PM
    Hi ans sorry about that code. It won't work. I don't know what I was thinking. I got mixed up with Visula basic.

    Try this, I tested this and it works.

    Private Sub cmdLogin_Click()
    If UserPassword = DLookup("UserPassword", "tblUsers", "UserID") Then
    Beep
    Beep
    Else
    MsgBox "Wrong Password-Try again"
    UserPassword = ""
    UserPassword.SetFocus
    End If
    End Sub

    Now you can add this line after Beep Beep
    Docmd.OpenForm,, "FormStudentMenu"

    I just used UserID as an Autonumber field and on the form I put a combo box like ypu did with UserNames.

    The row source for cboUsernames is SELECT UserID, UserName FROM tblUsers ORDER BY UserName;
    ColumnCount 2
    Bound Column 1
    Column Widthts 0",2"


    This should work well. I didn't bother with the 1 and 0 values. I don't think you need it. Just my opinion.

    Good luck with you BA

    Rob

    should be DoCmd Capital Cmd
    Sorry about the typo.

    I just noticed you are opening 1 of 2 different forms. You might need to isolate Usernames for Admin? Not sure about that curveball I just saw.
    Micromax's Avatar
    Micromax Posts: 22, Reputation: 1
    New Member
     
    #6

    Jul 8, 2011, 04:47 PM
    Comment on Micromax's post
    You may have to add a line of code after the DLookup function = 1
    DoCmd.OpenForm "frmName" Or DLookup function =2
    DoCmd.OpenForm "OtherfrmName"
    I'm not sure, Maybe Scott can solve this.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #7

    Jul 8, 2011, 04:54 PM

    The OP first posted on my blog on Login Security. I asked that he move here since its more suited to followups. I have asked repeatedly that he be more specific in what he needs. He posted a copy of the code he was using. But he has yet to define what about that code was not working or what error messages he has been getting.

    Without more specifics, we cannot help.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Something about Visual Basic. [ 3 Answers ]

May anyone tell me how to do this calculation,the code into Visual Basic? (Question) If the user inputs 15 and 3, the first number is a multiple of the second. If the user inputs 2 and 4, the first number is not a multiple of the second.

Visual basic coding [ 1 Answers ]

Assume that you are coding an object in the frmFriends form and you want to refer to the Text property of the txtPhone text box, which is in the frmNumbers form, which one of following could you enter into the Code window? FrmNumbers.txtPhone.Text or frmFriends.txtPhone.Text or...

Design a database application n Access or Visual Basic which can be used by a student [ 2 Answers ]

You have to design a simple application In Access and/or Visual Basic which can be used by a student joining a University to record details about himself, his course and his registration and fees paid for each year. Requirements: You should be able to add, update and delete details of...

Onveting from access to visual basic [ 1 Answers ]

Hello! I´ve heard that you can convert your access database to visual basic project. So I am asking you if somebody knows how to do it and with witch program? I hope you understand! Thanks hcjgh ;D


View more questions Search