Click to See Complete Forum and Search --> : Compile error
sridhartvmalai
October 2nd, 2001, 10:53 AM
My project starts with login form, after the password validation the form1 should be load.
My question is from the following code the compile error comming.
Variable not defined.
Private Sub cmdOK_Click()
If txtPassword = "password" Then
LoginSucceeded = True
Me.Hide
Load Form1
Else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
Please give me some solution
Sridhar
Cimperiali
October 2nd, 2001, 11:19 AM
This occur when you have a "Option Exlpicit" statement at the beginnig of code and you refer to a variable not defined with
Dim variable as ... Private variable as... Public variable as...
in your case:
LoginSucceeded seems to be the one
you should have somewhere a
Dim LoginSucceeded as boolean
However, I think you need this variable as public:
Public LoginSucceeded as boolean
and you could need it on top of code of your form (thus becoming a property of the form) or at top of a Bas module (=satndard module).
Another chance: does in your projeect exists a Form which is named "Form1"?
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
DSJ
October 2nd, 2001, 11:19 AM
Instead of "Load Form1" try Form1.Show
sridhartvmalai
October 2nd, 2001, 04:31 PM
Hi Cimperiali,
Whatever you said are already there in my login form.
Give me a more clue please.
Thanks
Sridhar
Cimperiali
October 3rd, 2001, 02:11 AM
Does not vb ide highlight the statement which causes the matter?
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Cimperiali
October 4th, 2001, 01:50 AM
'you sure the name of the variable LoginSucceeded
'had two "e" when you dim it?
private Sub cmdOK_Click()
If txtPassword = "password" then
'txtPassword must be the name of a textBox (not an arry of textboxes!).
'Check for the name to match!
LoginSucceeded = true 'I copied this, so here may be the mistake: one "e" may
' be enough...
'LoginSucceeded= a boolean maybe pubblic variable
me.Hide
'this code is in a form, not in a bas/class module
Load Form1
'Form1 must be the name of a form in your project. It should not
'be the same form where this code is
else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.