Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning to a Previous Form

Status
Not open for further replies.

okswug

IS-IT--Management
Feb 9, 2006
8
US
Kind of a stupid question maybe, but that is okay, as I am stumped. I am using VBA inside AutoCAD, but should be similar to using it in others...?

I have a Main form that opens, and I do stuff, and end up Hiding the Main form, and using a Child form. When I'm done with the Child, I want to go back to the place I called the Child Form from. When I Show the Main form, it doesn't go back to that spot. It executes the Main Form Initialize routine and sits there. I can't leave the Main form open either, because I get an error that the form is a Modal form and has to close before the Child is opened.

So, do you know how to solve my problem?

TIA
 
I don't know the AutoCAD model, but is there a property that indicates, say, "current position"? If so, you can save that value in a global variable and, presumably, go back with some kind of "set position"?

_________________
Bob Rashkin
 
You cannot show a modeless userform on top of a modal userform.
Check the properties of your child form. I think it must have "ShowModal" set to false. If it is set to True then VB will allow you to show it on top of the main form so when you dismiss the child form, the main form will be there on screen. You will not have to re-show it.
If you .Hide the main form, and then .Show it again, it shouldn't re-initialize. If you Unload the form and then show it again, it will re-initialize. If there is a crash in your code (all variable values are lost), when you re-show the main form it will re-initialize.

Why after all these years have you given up on AutoLisp?

Greg
(former draftman whose job is now performed by Bulgarians for $2 and hour on stolen workstations running pirated copies of AutoCad)
 
I have no problems with the following code (both forms modal):

' UserForm1 module:
Private Sub CommandButton1_Click()
Me.Hide
UserForm2.Show
MsgBox "UserForm2 closed"
Me.Show
End Sub

Private Sub UserForm_Initialize()
MsgBox "UserForm1 Initialize"
End Sub

' UserForm2 module:
Private Sub CommandButton1_Click()
Unload Me
End Sub

combo
 
Thaks for the help. I am off and running now...and LISP is still good for a lot of stuff, and we don't use Bulgarians. We use different nationalities with the same pirated copies of software.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top