Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

vB Project

  • 07-04-2003 4:23pm
    #1
    Closed Accounts Posts: 1,576 ✭✭✭


    Hio

    I'm currently working on a simple vB project for first year. Its just a simple video database program. The piece thats giving me grief tho is the user logins.

    I've linked up most of the forms with an MSaccess database. I've made a seperate table to store usernames and passwords. So an adminstrator could add remove accounts, and it would also be possible to change passwords.

    Altho I can't get this idea to work for the life of me :/

    I'm using a combobox to select my username..it may not be the best idea tho. Whats the easiest way to go about linking a database to get useraccounts and passwords.

    My 2nd trouble is with this:
    if passwordOK = True Then
        frmlogin.Hide
        loggedin = True
        MsgBox "Welcome, " & username, vbDefaultButton1, "Welcome"
    End If
    

    Which returns you to the main form, and once you've logged in it should enable one of two menu commands .
    1. Change Password
    2. Add New Account (If you logged in as admin)

    Yet, these menu's won't enable right away. I'm using the frm_activate event.

    I noticed that it works fine if I dont have a msgbox in there. I would like to keep it tho. ;o

    Thanks lads.


Comments

  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Originally posted by Kairo

    Yet, these menu's won't enable right away. I'm using the frm_activate event.

    Post the code for the form_activate event, I've a feeling you should put the code else where. Everytime you return to the main menu from another window (like the msgbox) you will fire this event. Ooh, Bardquiz, brb...

    back. As for usernames and the combobox. Will you not need to be logged onto the database before you return these? You could store them in a file or something but I'd recomend you just leave both fields blank. No point in giving half the game away.


  • Closed Accounts Posts: 1,576 ✭✭✭Kairo


    Private Sub Form_activate()
    If loggedin = True Then
        mnupasschange.Enabled = True
    End If
    
    If adminlogin = True Then
        mnuaddacc.Enabled = True
    End If
    End Sub
    

    Thats the main form code

    As for the login. I'm not too worried about wheter its a combo box or not. I just can't seem to be able to get the autentication to recognise the useraccounts table in my database.

    :/


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Originally posted by Kairo
    I've linked up most of the forms with an MSaccess database. I've made a seperate table to store usernames and passwords. So an adminstrator could add remove accounts, and it would also be possible to change passwords.

    Altho I can't get this idea to work for the life of me :/
    You’ll have to be more specific here.
    I'm using a combobox to select my username..it may not be the best idea tho. Whats the easiest way to go about linking a database to get useraccounts and passwords.
    Don’t use the data control. It’s just more trouble than it’s worth. Connect to your mdb directly.
    Yet, these menu's won't enable right away. I'm using the frm_activate event.
    Let’s say your main form is called frmMain - Try:
    if passwordOK = True Then
        frmlogin.Hide
        [b]fromMain.mnuaddacc.Enabled = True[/b]
        MsgBox "Welcome, " & username, vbDefaultButton1, "Welcome"
    End If
    


  • Closed Accounts Posts: 1,576 ✭✭✭Kairo


    Right..that solved the menu's problem, thanks Corinthian.

    I have a table on my access database which is called useraccounts. It has two fields. Username and Password. I was trying to use a data control, but I never managed to get it working.

    when I said I linked up most of the forms..I only meant that I was using a data control on them.

    How do you link to a database directly?

    We weren't shown how..so I don't know if I should use it, but I'd like to know how anyway.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Originally posted by Kairo
    How do you link to a database directly?
    Gosh, I’ve just realized how long it is since I've used DAO...

    DAO is probably the easiest way of bypassing the data control and connect to the database directly. This will give you way more flexibility where handling your data. Here’s a nice tutorial to get you started:

    http://www.thebestweb.com/vbarticles/daobasics.htm


  • Advertisement
  • Closed Accounts Posts: 8,264 ✭✭✭RicardoSmith


    This looks similar as using RDO or ADO. Is there a difference? Is there difference between RDO and ADO for that matter?


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    Originally posted by RicardoS
    This looks similar as using RDO or ADO. Is there a difference? Is there difference between RDO and ADO for that matter?

    In your average, everyday usage, nope. Not a hell of a lot.

    When you start getting to the more advanced stuff, you find that DAO is a bit too "Access-centric". RDO is pretty ok for databases in general, and ADO was designed to be able to access non-RDBMS data sources as well......its extensible which I dont believe the others are.

    Mostly what you find is that a new technology is introduced to overcome a critical shortfall in one of the earlier ones, and then as new features come along, they are most typically only added to the new tech, further widening the gap.

    jc


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    the other important thing is that DAO is no longer supported you should really use ADO

    as for
    fromMain.mnuaddacc.Enabled = True
    you should really treat vb forms as classes
    so you should create a private variable maybe something like
    bIsAdmin
    and then set via a propery on login

    Then on the form you can just check the value of bIsAdmin


  • Closed Accounts Posts: 1,576 ✭✭✭Kairo


    Better again..will do :)

    thanks lads.


Advertisement