View Full Version : Variable not defined when killing scroll wheel


NascarBaritone
02-03-2009, 08:40 AM
I am getting a variable not defined error when compiling my script. The variable pointed to is the "vardoc" under my OnClick function of the Edit button. However, if I remove all of the CMouseWheel script the variable is defined and I do not get an error. Any idea what I need to fix if I keep the CMouseWheel script in there?

Here is my code:


Option Compare Database
Option Explicit
'Declare a module level variable as the custom class
'and give us access to the class's events
Private WithEvents clsMouseWheel As CMouseWheel
Private Sub Form_Load()
'Create a new instance of the class,
'and set the class's Form property to
'the current form
Set clsMouseWheel = New CMouseWheel
Set clsMouseWheel.Form = Me
'Subclass the current form by calling
'the SubClassHookForm method in the class
clsMouseWheel.SubClassHookForm
End Sub
Private Sub Form_Close()
'Unhook the form by calling the
'SubClassUnhook form method in the
'class, and then destroy the object
'variable

clsMouseWheel.SubClassUnHookForm
Set clsMouseWheel.Form = Nothing
Set clsMouseWheel = Nothing
End Sub
Private Sub clsMouseWheel_MouseWheel(Cancel As Integer)
'This is the event procedure where you can
'decide what to do when the user rolls the mouse.
'If setting Cancel = True, we disable the mouse wheel
'in this form.
Cancel = True
End Sub
Private Sub cmdBack_Click()
wbbWebsite.GoBack
End Sub
Private Sub cmdForward_Click()
wbbWebsite.GoForward
End Sub
Private Sub Edit_Click()
Dim X As String
Dim Y As String
vardoc = Me!LastName.Value & ", " & Me!FirstName.Value & " " & Me!Branch.Value & "\OBA\" & Me!Branch.Value & " " & Me!FirstName.Value & " " & Me!LastName.Value & " " & "OBA"
X = Me!Branch.Value
Y = Left(Me!LastName.Value, 1)
If X = "RET" And Y >= "A" And Y <= "G" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Sales Office\Last Name A-G\" & vardoc & ".doc"
ElseIf X = "RET" And Y >= "H" And Y <= "N" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Sales Office\Last Name H-N\" & vardoc & ".doc"
ElseIf X = "RET" And Y >= "O" And Y <= "Z" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Sales Office\Last Name O-Z\" & vardoc & ".doc"
ElseIf X = "HO" And Y >= "A" And Y <= "G" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Home Office\Last Name A-G\" & vardoc & ".doc"
ElseIf X = "HO" And Y >= "H" And Y <= "N" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Home Office\Last Name H-N\" & vardoc & ".doc"
ElseIf X = "HO" And Y >= "O" And Y <= "Z" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Home Office\Last Name O-Z\" & vardoc & ".doc"
ElseIf X = "SL" And Y >= "A" And Y <= "G" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Home Office\Last Name A-G\" & vardoc & ".doc"
ElseIf X = "SL" And Y >= "H" And Y <= "N" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Home Office\Last Name H-N\" & vardoc & ".doc"
ElseIf X = "SL" And Y >= "O" And Y <= "Z" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Home Office\Last Name O-Z\" & vardoc & ".doc"
ElseIf X = "TERM" And Y >= "A" And Y <= "G" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Terminated\Last Name A-G\" & vardoc & ".doc"
ElseIf X = "TERM" And Y >= "H" And Y <= "N" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Terminated\Last Name H-N\" & vardoc & ".doc"
ElseIf X = "TERM" And Y >= "O" And Y <= "Z" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Terminated\Last Name O-Z\" & vardoc & ".doc"
ElseIf X >= "1" And Y >= "A" And Y <= "G" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Reps\Last Name A-G\" & vardoc & ".doc"
ElseIf X >= "1" And Y >= "H" And Y <= "N" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Reps\Last Name H-N\" & vardoc & ".doc"
ElseIf X >= "1" And Y >= "O" And Y <= "Z" Then
vardoc = "K:\Corporate Compliance\EQSALES\COMPLIANCE\Registered Reps Database\Reps\Last Name O-Z\" & vardoc & ".doc"
End If
If Dir(vardoc) = "" Then
MsgBox Me!FirstName.Value & " " & Me!LastName.Value & " does not have an OBA form"
Else
Application.FollowHyperlink (vardoc)
End If
End Sub
Private Sub Form_Current()
DoCmd.GoToControl "CRD"
If Len([OBAFile]) > 0 Then
wbbWebsite.Navigate URL:= (http://www.access-programmers.co.uk/forums/=)[OBAFile]
Else
MsgBox Me!FirstName.Value & " " & Me!LastName.Value & " does not have an OBA form"
End If
End Sub

ByteMyzer
02-03-2009, 09:46 AM
You need to define vardoc:

Private Sub Edit_Click()
Dim X As String
Dim Y As String
Dim vardoc As String