RE: Compile Error: Variable Not Defined
- From: FGM <FGM@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 17 Aug 2009 09:12:01 -0700
Take out Option Explicit and see if it runs without it. I use it but maybe
you have a variable that is not declared and it is not showing. Usually it
highlights the variable that is not defined.
"Tara" wrote:
FGM, I just checked, and require variable declaration is not on, and the.
General Declarations do require Option Explicit.
I'd appreciate any other help you can give.
"FGM" wrote:
Under the VBA window check Tools then Editor tab and see if require variable
declaration is on.
Also, on the VBA input window General Declaration see if it requires Option
Explicit.
Option Compare Database
Option Explicit
"Tara" wrote:
All of our databases have Login forms. I've reused these forms and the
associated tables many times in the past with other databases (the original
Login form was part of a database that already existed before I started
working here). Now, for the first time, I'm having a problem with it.
Obviously, the code indicates that the variable isn't defined, so I defined
it. Unfortunately, it then just goes on to the next Case statement, and
breaks there. In looking at our other databases, I realized that the
variables aren't defined in those either, at least not that I can see, and
they work perfectly. I'm not proficient at all with coding, and I'm lost
trying to figure out what the underlying issue is. Here's the code
involved...the code originally broke at Case ltNone. Any help is greatly
appreciated!
Private Sub Form_Load()
Dim rst As New ADODB.Recordset
Dim strUser As String
On Error GoTo ErrHandler
rst.Open "SysMisc", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
bUsePasswords = rst.Fields("UsePasswords")
Select Case rst.Fields("Login")
Case ltNone
cmdEnter_Click
Case ltWindows
strUser = GetUser
rst.Close
rst.Open "SELECT * FROM sysEmployees WHERE
sysEmployees.WindowsLogin='" & strUser & "'", CurrentProject.Connection,
adOpenStatic, adLockReadOnly
If rst.RecordCount > 0 Then
Me.comEmployeeID = rst.Fields("EmployeeID")
If bUsePasswords = False Then
cmdEnter_Click
Else
Me.txtPassword.Visible = bUsePasswords
End If
Else
Err.Raise 550, "sysLogin.Form_Load", "Unauthorized access
attempted: " & strUser
rst.Close
Set rst = Nothing
DoCmd.Quit
End If
Case ltDatabase
Me.txtPassword.Visible = bUsePasswords
End Select
rst.Close
ExitHere:
Set rst = Nothing
Exit Sub
ErrHandler:
If Err.Number = 550 Then
MsgBox Err.Description
Application.Quit
Else
MsgBox Err.Description
End If
Resume ExitHere
End Sub
- Follow-Ups:
- RE: Compile Error: Variable Not Defined
- From: Tara
- RE: Compile Error: Variable Not Defined
- References:
- Compile Error: Variable Not Defined
- From: Tara
- RE: Compile Error: Variable Not Defined
- From: FGM
- RE: Compile Error: Variable Not Defined
- From: Tara
- Compile Error: Variable Not Defined
- Prev by Date: Path direction
- Next by Date: RE: Compile Error: Variable Not Defined
- Previous by thread: RE: Compile Error: Variable Not Defined
- Next by thread: RE: Compile Error: Variable Not Defined
- Index(es):
Relevant Pages
|