Results 1 to 29 of 29

Thread: Login Before Access

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    Unhappy Login Before Access

    Hello
    Im trying to create a new form(form1), in this form the User Has to login with a userid and password in other to see form2 and there should be an option for new users to register on form1..And the program must be able to keep newuserids and passwords. Can anyone help me? Thanks

  2. #2
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Login Before Access

    this has been discussed a million times already, try searching the forum before posting.

  3. #3
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Login Before Access

    here is the example i promised you in the pm. havent tested it but it should work. itll give you an idea anyways.
    Attached Files Attached Files

  4. #4
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Login Before Access

    go into modDatabase and change the first sub to this:
    VB Code:
    1. Public Sub EstablishDatabaseConnection()
    2.     'the variables are set within the module (modVariables), now lets set the
    3.     'instance of these variables
    4.     'MAKE SURE YOU SET A REFERENCE TO Microsoft ActiveX Data Objects 2.x
    5.     '(Project > References)
    6.     Set objADOCon = New ADODB.Connection
    7.    
    8.     'this is the connection string to access the database (do not modify)
    9.     With objADOCon
    10.         .CursorLocation = adUseClient
    11.         .ConnectionString = "DRIVER={Microsoft.Jet.OLEDB.4.0};" _
    12.                           & "DATA SOURCE=" & App.Path & strDBFile & ";" _
    13.                           & "USER ID=" & strUN & ";" _
    14.                           & "PASSWORD=" & strPW & ";"
    15.         .Open .ConnectionString
    16.     End With
    17. End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    Re: Login Before Access

    Ok, i did just that and when i open the fromAddUser and try to add a new user i get this error. " Sub or Function Not Defined" and this place gets highlighted in the codes..

    Private Sub cmdAdd_Click()
    EstablishDatabaseConnection

    Also when i open frmLoginScreen and type in a username and password and click on login i see a visual basic run time error..

    "Run-Time error '-2147467259 (80004005)':

    [Microsoft][ODBC Driver Manager] Data source name too long"


    What might be the problem?

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    Re: Login Before Access

    this place gets highlighted in the code...

    .Open .ConnectionString for the Run Time Error

  7. #7
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Login Before Access

    im at work right now, will look into it when i get home from work. should be around 6pm est.

  8. #8

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    Re: Login Before Access

    Ok.. will be waiting.. thanks

  9. #9
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Login Before Access

    Dont create the connection object again and again if its just the same database. Set up the public connection in a BAS module on program start then close it on program end (in your Unload All procedure), and not per procedure call.

    .Open .ConnectionString ...If you've already assigned the connection string to .ConnectionString then a simple .Open would suffice.

    What value are you assigning to data source or what's "App.Path & strDBFile"? You may need to move your app directory closer to the root.

  10. #10

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    Re: Login Before Access

    Same Error.. You can look in the codes in the example.zip :S Im now confused

  11. #11
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Login Before Access

    Does the username/password have to be stored in a database or could you put it in a standard (encrypted) text file?

  12. #12
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Login Before Access

    Quote Originally Posted by DigiRev
    Does the username/password have to be stored in a database or could you put it in a standard (encrypted) text file?
    if youre going to use a db anyway, whats the point in using a textfile?

  13. #13
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Login Before Access

    Oh I didn't know he was already using a db in his project.

  14. #14

  15. #15
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Login Before Access

    Quote Originally Posted by DigiRev
    Oh I didn't know he was already using a db in his project.
    he wanted to use a db but he didnt know how, so asked for an example, thats when i provided an example (was untested and written from memory, had to make slight changes)

  16. #16

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    Re: Login Before Access

    Thanks a lot guys.. ive got it now .. now the last question is .. i alreay have form1 how do i link the 2 together, so after the person logins he sees form1. I hope you understand what im saying.. I tried changing the

    frmMain.Show vbModal to form1.show and saved form1 in the same folder but not working.. :s

  17. #17

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    Re: Login Before Access

    I think theres a problem.. when i added the first user i could login with that credentials but when i add another user i cannot login with the second username and password.. what might be wrong

  18. #18
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Login Before Access

    Quote Originally Posted by mymicky
    Thanks a lot guys.. ive got it now .. now the last question is .. i alreay have form1 how do i link the 2 together, so after the person logins he sees form1. I hope you understand what im saying.. I tried changing the

    frmMain.Show vbModal to form1.show and saved form1 in the same folder but not working.. :s
    where it says frmMain.Show vbModal, just change it to form1.Show vbModal (it will work because it works with frmMain

  19. #19
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Login Before Access

    Quote Originally Posted by mymicky
    I think theres a problem.. when i added the first user i could login with that credentials but when i add another user i cannot login with the second username and password.. what might be wrong
    check the access database for the username and password of the second user. if it works for one user, it will work for others

  20. #20

  21. #21

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    Re: Login Before Access

    i checked the database and the other users are in it.. but doesnt work with other users. did you edit anything?

  22. #22

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    Re: Login Before Access

    and why cant i start frmLoginScreen at once.. if i open that without opening the project it gives an error why is that

  23. #23
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Login Before Access

    not having any problems here. post #3 was updated and seems to work without a problem. why would you want to open frmMain without logging in first?

  24. #24

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    Re: Login Before Access

    Ok, just downloaded the example again and i tested user1 pass1 .. works fine but when i tried to add a new user i got this compile error ..

    Variable Not Defined.. and here gets higlighted strUsersTable

    its somewhere here

    Private Sub cmdAdd_Click()
    EstablishDatabaseConnection

    strSQL = "SELECT * FROM " & strUsersTable
    objADOCon.Execute strSQL

    OpenRecordset

  25. #25

  26. #26

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    Re: Login Before Access

    i do have the current version in post 3... try adding a new user .. it says this variable is not defined (strUsersTable) ...Can someone else try it ?

  27. #27

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    Re: Login Before Access

    Ok i compared the new one with the old ones and changed some of the codes.. now works perfectly.. thanks ... But i must open project1.vbp then i click start before it starts .. But its still coool

  28. #28
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Login Before Access

    Quote Originally Posted by mymicky
    i do have the current version in post 3... try adding a new user .. it says this variable is not defined (strUsersTable) ...Can someone else try it ?
    it is declared i had no problems my end.

  29. #29
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Login Before Access

    Quote Originally Posted by mymicky
    Ok i compared the new one with the old ones and changed some of the codes.. now works perfectly.. thanks ... But i must open project1.vbp then i click start before it starts .. But its still coool
    you have to open the project file regardless of the project, thats how vb is

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width