Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Compile Error?


Please help! I compiled my VBA project and I got the following message.
"Compile Error Variable Not Defined". When I clicked on debug it took me to
the following code and highlighted the line frmMyUserform.Show vbModeless.
Can someone please help me understand why. Although my form is working fine.
Is this something I need to fix? If so how? Thank you for any help.

Private Sub UserForm2_Initialize()
Load UserForm2
UserForm2.Show
frmMyUserform.Show vbModeless

Me.FormDate = Format(Date, "mm-dd-yyyy")

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Compile Error?

Should be

UserForm2.Show vbModeless

delete the line frmMyUserform.Show vbModeless

--
Regards,

OssieMac


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Compile Error?

I'm guessing that this code is behind the userform.

If that's true, then you can't rename the procedure names--use:
Private Sub UserForm_Initialize()

And you don't need these two lines:
Load UserForm2
UserForm2.Show


And I'm still guessing that frmMyUserForm is a different userform--if that's
true, do you really want to show that when userform2 is shown?

If it's the same as the userform that's being loaded (and I guessed wrong), then
remove that line, too.

TotallyConfused wrote:

Please help! I compiled my VBA project and I got the following message.
"Compile Error Variable Not Defined". When I clicked on debug it took me to
the following code and highlighted the line frmMyUserform.Show vbModeless.
Can someone please help me understand why. Although my form is working fine.
Is this something I need to fix? If so how? Thank you for any help.

Private Sub UserForm2_Initialize()
Load UserForm2
UserForm2.Show
frmMyUserform.Show vbModeless

Me.FormDate = Format(Date, "mm-dd-yyyy")

End Sub


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Compile Error?

I am guilty of not reading and understanding the question well enough. For
that matter I am still not sure I fully understand it now. maybe Dave has
answered your question. However, the following information might also help.

If you have 2 forms open and you want to be able to work on both then they
should both be modeless.

If you show a modal form then all following code stops in the sub that shows
the form until you close the form and then the remaining code in the sub
executes.

Therefore if you open a modal form and in the same sub you try to show
another form after it then the second form will not show until the first one
is closed.

If you open a modeless form then the remaining code in the sub continues to
execute. If the code shows a modal form after the modeless form then both
forms will show but you are stuck on the modal form and cannot focus on the
modeless form until the modal form is closed.

--
Regards,

OssieMac

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bubble sort Error (Compile Error: Type Mismtach) Excel Monkey[_2_] Excel Programming 6 April 24th 09 12:16 AM
VBAProject name compile error, not defined at compile time Matthew Dodds Excel Programming 1 December 13th 05 07:17 PM
error message: compile error, argument not optional Pierre via OfficeKB.com Excel Programming 3 September 5th 05 03:45 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM


All times are GMT +1. The time now is 10:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"