Elmorte
08-10-2001, 11:36 PM
Heya,
I'm a complete newbie to VBA (not VB). What I would like to know is how I can access the data in the tables/results of the queries and chuck'em into variables. One example is a login form that runs on start-up. I have a table with the login and pass, and I want the form to access the data in that table to be able to verify the login.
Any helpful that could get me started is appreaciated.
Thanx in advance,
El Morte
Neil 2001
08-12-2001, 07:02 AM
You could try something basic like the following. You would just call on the function sending in the username and password strings and see if a record was found... Regards Neil. Hope it helps a bit !
Private function CheckPass(dim User as string, Dim Pass as string) as boolean
'Function checks if username and password exists
dim db as database 'database variable
dim rs as Recordset 'table variable
dim strSQL as string 'SQL statement
strSQL = "Select * from [TABLENAME] Where [USERFIELD] = '" & User & "' And [PASSWORDFIELD] = '" & Pass & "'"
set db = currentdb
set rs = db.openrecordset(strSQL)
if rs.eof = true then 'record not found
CheckPass = False
else
CheckPass = True
end if
rs.close
db.close
End Function
Elmorte
08-14-2001, 08:06 PM
Thanx Neil, I used the code and I have one problem. I get a type mismatch error when it comes to this line
<font color=blue>set rs = db.openrecordset(strSQL) </font>
The sqlString looks like this:
<b>Select * from [Salespersons] Where [Name] = 'Joe Blows' And [LogonPassword] = 'pass';</b>
so I'm really not clear on what the problem is.
Thanx again,
El Morte
Neil 2001
08-15-2001, 08:24 AM
Check to see if you have the following references (or equivalent) in the tools > References menu selected when in code design...
Visual Basic For Applications
Microsoft Access 8.0 Object Library (or similar)
Microsoft DAO 3.51 Object Library
Hopefully this will resolve it. When you type in the Dim rs... line of code does it list Recordset in the list after you type the word 'as '. If it does it should work. Ohterwise repost your code to me at bigandy_2000@hotmail.com and I will see if there is anything noticable....Neil