I am using code to log on to an application using an internal Database and Recordset.

The variables are declared as follows:

Dim DB As Database
Dim RS As Recordset
Dim stLoginName As String
Dim stPassword As String

The code I use is as follows:

Set DB = OpenDatabase(stDatabaseName, False, False)
Set RS = DB.OpenRecordset("Select * From [PROGRAM SECURITY] where Login = '" & stLoginName & "'")

Login is a text type in an Access database
stLoginName is the contents of a text box on my login screen

On the 2nd line of code, I get run-time error 13 Type Mismatch

If I do not use an Option Explicit and do not declare the variables, the code works fine.

As soon as I add an Option Explicit and declare the variables, the run time error occurs.

I use this same code in all my other programs I have created and have never run into this before. Can anyone help me please. It is driving me nuts.... :-)