I posted this in General VB, but I'll post it here too.

I am having problems with DAO. I have this same code in a different project, and it works fine, but I am trying to use the same code in a different program to open a table and get info out of it.
OK this code works fine, to get an item out of the table:
VB Code:
  1. Set db = OpenDatabase("C:\Windows\Desktop\inventory.mdb")
  2. strSQL = "SELECT * FROM Current WHERE ID = " & txtID.Text
  3. Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
  4. If rs.RecordCount > 0 Then
  5.     'Text1.Text = rs!ItemNo & "" 'substitute real field names
  6.     buff = rs!Price '& ""
  7.     lstReceipt.AddItem buff
  8.     txtID.Text = ""
  9. Else
  10.     MsgBox "No Match found for that ID.", vbCritical
  11. End If
  12. rs.Close
  13. db.Close

But then I use this code to get info out of a different database and table:
VB Code:
  1. Private Sub cmdLogin_Click()
  2. Uname = txtUsername.Text
  3. Pword = txtPassword.Text
  4. Set db = OpenDatabase("C:\Windows\Desktop\users.mdb")
  5. MsgBox "got here"
  6. strSQL = "SELECT * FROM usertable WHERE Username = " & Uname
  7. Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
  8. If rs.RecordCount = 0 Then MsgBox "No user by the name " & Uname & ". Please check the name you entered.", vbInformation: Exit Sub
  9. TestPass = rs!Password
  10. If TestPass = Pword Then MsgBox "Correct password!"
  11. rs.Close
  12. db.Close
  13. End Sub

and I get an error with the dbOpenDynaset variable. It says somthing about Too few parameters, expected 1. So I change dbOpenDynaset to a 1, and it gets an error opening the table. This is frustrating! Just incase you are wondering, I HAVE added a reference to the ADO library, just like in the other project, and I have declared all my variables... I just don't want to post all the code.

Please don't mention ADO, cause I have had so many f**king problem with ADO, it's not even funny.

Thanks in advance
-Joey