Results 1 to 13 of 13

Thread: [Resolved] compile error: variable not defined

Hybrid View

  1. #1

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Resolved [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.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: compile error: variable not defined

    Quote 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

  3. #3

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: compile error: variable not defined

    Quote 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

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: compile error: variable not defined

    Quote Originally Posted by LaVolpe
    You use Unload to unload an object, i.e., Unload Me
    This is all you need.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.

  6. #6

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: compile error: variable not defined

    Quote 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

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.

  8. #8

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: compile error: variable not defined

    Quote 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

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.

  10. #10

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: compile error: variable not defined

    Quote 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

  11. #11
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    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

  12. #12
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: compile error: variable not defined

    Use Option Explicit to force you to declare all your variable so that you wont have this problem.

  13. #13

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: compile error: variable not defined

    Quote 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
  •  



Click Here to Expand Forum to Full Width