Results 1 to 6 of 6

Thread: Login

  1. #1
    Guest

    Talking

    Another newborn baby in the world of VB ;~| >uha...uha...uha...ha?..hahaha...hahaha!

    I don't know how I can 'link' my login window (with Username as combobox, Password as textbox) to my Access 97 table. Please teach me how...or better give me a code that acts like the "WinNT Login" (but in my app, a new user can add his record directly to the login window).

    [Edited by VB Q and Q on 04-28-2000 at 03:23 AM]

  2. #2
    Guest
    You need an algorythm something like this:
    Code:
    If newUser then
      add new user to the database
    Else
      verify user password
    End if
    You'll need to either use a data control or open a workspace and a database to make the actual connection to the access file (see the MSDN library)

    Once you have that, formulate a SQL string like these:
    Code:
    'To add the new user:
    strSQL = "INSERT INTO tablename (columnname1, columnname2) VALUES " & cboUser.text & ", " & txtPasswords.text
    
    'To verify the password:
    strSQL = "SELECT * FROM tablename WHERE usernamecolumn = '" & cboUser.text & "'"
    Hope that helps.

    -John

  3. #3
    Guest

    Wink Type mismatch

    Thank you.
    A part of my code looks like this:
    ------------------------------------------------------------
    Dim Db As Database
    Dim Rs As Recordset
    Dim SQLString As String
    Set Db = OpenDatabase(...the path...)
    SQLString = "SELECT * FROM ListUsers WHERE Username = '" & _
    cmbUserName.Text & "'"
    Set Rs = OpenRecordset(SQLString)
    ------------------------------------------------------------
    BUT when I press the OK button (during run-time), there was a "run time error '13' " -> type mismatch. It seems that OpenRecordset(SQLString) did not return a recordset...or maybe my query is wrong.

  4. #4
    Guest
    The OpenRecordset method takes different arguments when called on
    different objects (ie. a TableDef, a Database, etc)
    You need to open the recordset in the context of the database
    (remember you could open more than one db at a time)

    Try this:
    Set Rs = Db.OpenRecordset(SQLstring)


  5. #5
    Guest

    Red face Oopsssorry.....

    It was a typo error...actually I included the database object 'Db' in the line, i.e.,
    Set Rs = Db.OpenRecordset(SQLString).
    I tried to run the code if I omit the 'Db', and your correct, it is an error to do so. But the problem remained the same (Db included), "run time error '13' " -> type mismatch.
    I also tried to replace
    Set Db = OpenDatabase(...the path...)
    with
    Set Db = DBEngine.Workspaces(0).OpenDatabase(...the path...)
    but the compiler echoed me the same error.

    [Edited by VB Q and Q on 05-02-2000 at 11:21 PM]

  6. #6
    Guest

    Cool Data Type

    Wait...just for a while I discovered that if I change the data type of Rs from Recordset to Object, the whole app will work (although the app is not yet complete).
    I just want to ask if using a 'generic' data type like Object will cause a side effect(s).
    And I don't really know the reason why the compiler rejects the Recordset and accepts the other (in my app).

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