Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    selection wrong (2000)

    wath is wrong in this selction...
    RSD1.Open "select * from userpass where username = '" & txtUserName & "' and password = '" & txtPassword & "'"

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: selection wrong (2000)

    The correct general syntax for opening a recordset (let's call it "rs") in the current database is:

    Set rs = Currentdb.OpenRecordset (" ... SQL ...", dbOpenDynaset)
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: selection wrong (2000)

    In effect...
    I have a form with 2 text box frmLogin.txtPassword and frmLogin.txtUserName.
    Now i want to seelct with statement "where" the value in all 2 textbox and controll the count.
    If the count = 0 naturally the user or password is wrong because the selection count is =0
    Note: i have dimensioned PASSOWRD and USER as string in Global declaration in other module
    Problem is because the count return = 1

    Naturally other wauy are welcome, tks.
    Thsi si my conn:
    Sub main()
    Set DB1 = DBEngine.OpenDatabase("GCD01F4500DATIPUBBLICAANTIR ICANAGRAFICA.MDB")
    frmSplash.Show
    End Sub


    Private Sub cmdOK_Click()

    Dim TEST_COUNT As Long
    PASSOWRD = frmLogin.txtPassword
    USERNAME = frmLogin.txtUserName
    Set RSD1 = DB1.OpenRecordset("select * from USERPASS where username = USERNAME and password = PASSWORD")
    TEST_COUNT = RSD1.RecordCount

    If RSD1.RecordCount = 0 Then
    MsgBox "PASSWORD O USER NON CORRETTI", vbCritical, "..::GESTIONE COPE ::.."
    End
    Else
    MDIForm1_.Show , vbModal
    Set RSD1 = Nothing
    Set DB1 = Nothing
    End If

    End Sub

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: selection wrong (2000)

    The line

    Set RSD1 = DB1.OpenRecordset("select * from USERPASS where username = USERNAME and password = PASSWORD")

    should be

    Set RSD1 = DB1.OpenRecordset("select * from USERPASS where username = " & Chr(34) & USERNAME & Chr(34) & " and password = " & Chr(34) & PASSWORD & Chr(34))

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: selection wrong (2000)

    TKS!
    Now Work...

Posting Permissions

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