-
Nov 1st, 2007, 02:34 PM
#1
Thread Starter
Banned
[Resolved] compile error: variable not defined
I have a problem with the code. When I call the msgbox to quit the program and on the msgbox appeared to come on my screen, when I clicked cmdcancel I have received error: Compile error: variable not defined
Code:
Private Sub cmdCancel_Click()
Unload Quit
End Sub
I don't know what's wrong, I bet that Unload Quit are incorrect. What other way that I can tell the form to cancel one dialog because I am running two dialogs??
I'm sorry to make another thread but have received an error which it didn't means that I am spamming the forum. So I am here asking for advice which I would like to get resolve it asap!!!!!
Thanks,
Mark
Last edited by Mark103; Nov 2nd, 2007 at 07:15 AM.
-
Nov 1st, 2007, 02:36 PM
#2
Re: compile error: variable not defined
Originally Posted by Mark103
Code:
Private Sub cmdCancel_Click()
Unload Quit
End Sub
What is Quit? You use Unload to unload an object, i.e., Unload Me
-
Nov 1st, 2007, 02:40 PM
#3
Thread Starter
Banned
Re: compile error: variable not defined
Originally Posted by LaVolpe
What is Quit? You use Unload to unload an object, i.e., Unload Me
Thanks, but received the same error
Code:
Public Property Get QuitMe() As VbMsgBoxResult
QuitMe = miQuitMe
End Property
what's wrong??
Mark
-
Nov 2nd, 2007, 06:57 AM
#4
Re: compile error: variable not defined
Originally Posted by LaVolpe
You use Unload to unload an object, i.e., Unload Me
This is all you need.
-
Nov 1st, 2007, 02:51 PM
#5
Re: compile error: variable not defined
No, you won't receive an error on Unload Me. You are recieving an error in a different routine. Again. what is miQuiteMe? Are you using Option Explicit at the top of your form? You should be. And then run your project by pressing Ctrl+F5 to find all your errors, one at a time.
Edited: typo, should have typed Ctrl+F5 - fixed.
Last edited by LaVolpe; Nov 1st, 2007 at 02:55 PM.
-
Nov 1st, 2007, 02:56 PM
#6
Thread Starter
Banned
Re: compile error: variable not defined
Originally Posted by LaVolpe
No, you won't receive an error on Unload Me. You are recieving an error in a different routine. Again. what is miQuiteMe? Are you using Option Explicit at the top of your form? You should be. And then run your project by pressing Ctrl+5 to find all your errors, one at a time.
Yes I am using Option Explicit at the top of my form. I don't know what's wrong with the code (QuitMe = miQuitMe)that i have received the same error when I have refixed Unload Me??
Thanks,
Mark
-
Nov 1st, 2007, 03:00 PM
#7
Re: compile error: variable not defined
What is miQuitMe? It must not be a numeric variable or it isn't declared anywhere? This is your code, you should know what that variable is or is suppose to be.
-
Nov 1st, 2007, 03:04 PM
#8
Thread Starter
Banned
Re: compile error: variable not defined
Originally Posted by LaVolpe
What is miQuitMe? It must not be a numeric variable or it isn't declared anywhere? This is your code, you should know what that variable is or is suppose to be.
It tell the form to quit the program. Why do the error come with the same reasons that I have received?? How can we refix it??
Thanks,
Mark
-
Nov 1st, 2007, 03:07 PM
#9
Re: compile error: variable not defined
Declare it. That's why you are getting the error, nowhere in your code do you have a statement like Dim miQuitMe As ....
Declaring it will fix that one error, but unless you actually assign it a value somewhere in your code, its value will always be zero, null.
Again, this is your code, you should know what you want that variable to be declared as and what its value should be. We won't know that.
-
Nov 1st, 2007, 05:11 PM
#10
Thread Starter
Banned
Re: compile error: variable not defined
Originally Posted by LaVolpe
Declare it. That's why you are getting the error, nowhere in your code do you have a statement like Dim miQuitMe As ....
Declaring it will fix that one error, but unless you actually assign it a value somewhere in your code, its value will always be zero, null.
Again, this is your code, you should know what you want that variable to be declared as and what its value should be. We won't know that.
How we can fix the error then?? I have no idea what's the error is and I have no virtually idea how I could fix it. Maybe just use QuitMe which will fix my problem??
Thanks,
Mark
-
Nov 1st, 2007, 06:18 PM
#11
Re: compile error: variable not defined
I read this thread at least 15 times and I still don't understand the problem... something with a messagebox and unloading a form.
Do you want to show a messagebox to ask the user if a form should be unloaded?
Code:
Private Sub Command1_Click()
If MsgBox("Do you want to unload this form?", vbQuestion + vbYesNo, "Confirmation") = vbYes Then
Unload Me
End If
End Sub
-
Nov 2nd, 2007, 01:29 AM
#12
Re: compile error: variable not defined
Use Option Explicit to force you to declare all your variable so that you wont have this problem.
-
Nov 2nd, 2007, 06:57 AM
#13
Thread Starter
Banned
Re: compile error: variable not defined
Originally Posted by randem
Use Option Explicit to force you to declare all your variable so that you wont have this problem.
I have done this. Problem resolved!
Thanks,
Mark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|