Click to See Complete Forum and Search --> : Login
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]
You need an algorythm something like this:
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:
'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
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.
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)
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]
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).
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.