Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

Operation is not allowed when the object is closed...vb6

From Form1, via command1, I am opening Form2 (this works ok).  Although it is not necessary to click on command1 again,  because Form2 is already open, I get above error message when I do so.  And, to get rid of it one has to use Ctrl+Alt+Del keys to exit the vb application.

I tired to put break lines on command1_Click and Form_Active to see what lines causing the error.  I haven't been able to determine it.  Do you have any idea what this error exactly means and how I can handle it?

Thanks.
Avatar of avi247
avi247

1. What line throws this error? i.e. whats in your Command1_click method.
2. Is there anything you are doing when you open Form2, i.e. on Form2_load are any database or operations being done?
3. Is there any object in scope of Form1\Command1  and you are referencing in Form2
How do you open Form2?

What code is in Form_Load ?

What is in Comman_Click?
SOLUTION
Avatar of TheClickMaster
TheClickMaster
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Eghtebas

ASKER

avi247,

Re:>1. What line throws this error?
"I haven't been able to determine it." see the question for more.

Re:> i.e. whats in your Command1_click method.
Form2.Show '<-- first time works but the second time around gives error

Re:>2. Is there anything you are doing when you open Form2, i.e. on Form2_load are any database or operations being done?
I have some code to put the Form1 on top and move around on got focus (I removed them, the same difference).

Re:>3. Is there any object in scope of Form1\Command1  and you are referencing in Form2
No.
---------------------------------
Erick37, Please see above response to avi247.
----------------------------------
TheClickMaster, I am clicking on a lable, no button to enable it.
---------------------------------
abith, I tried it didn't work.
---------------------------------
To all:

I am new to VB, I need the proper code to open a form and close to get back to the original form.  In my case, the original form stays visible, the second form opens and attaches to the original form.

Regards,

Mike
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Erick37,

When I put break point, it doesn't produce error.  This becuase when if goes to code window, it also sets focus to the form (or form's code window).  This is why I tried to put break in Form_GotFocus and Form_Active events.  I have tried everything I know but I wasn't able to find the line which produces error.

I will take a look at your links now.

Thanks,

Mike
I'm sorry, I don't follow you.  Were you able to step through the code (F8)?  

And just to be clear - you are not connected to or referencing any database?
Erick37,

I have a routine to store some info in the backend.mdb (in Form_Deactivate).  rs.Colse is the line the error occurs.  I have to make sure rs (public variable) is not set to Nothing, I guess.  brb
I guess we have nailed it.  By mistake, I was setting my variables to nothing in Form_Deactivate.  I moved them to Query_Unload.  I will do some more tests with it and let you know about it.

Mike
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi eghtebas

make it a habit to use following code..

if rs.state = adOpen then rs.close
if rs.state = adclosed the rs.open...

me  too had this problem some time back,, since them i've statred using this b4 i open or close an object.. i check its state..first..

:))
The problem was a connection to the backend database prematurally was being set to noting.