|
-
Jul 14th, 2002, 08:32 PM
#1
Thread Starter
^:^...ANGEL...^:^
[ RESOLVED ]...Unloading Forms...
VB Code:
Private Sub cmdBack_Click()
frmMain.Show
Dim frm As Form
For Each frm In Forms
If frm <> frmMain Then
Unload frm
Set frm = Nothing
End If
Next frm
End Sub
What is wrong with this code...???
Gives compile error: Type mismatch
Hope some one can fix it...!!!
Cheers...
Last edited by wrack; Jul 15th, 2002 at 09:18 PM.
-
Jul 14th, 2002, 08:37 PM
#2
Hyperactive Member
which line gives you the error? Try using Unload Me and not using the Set frm = Nothing and see if that works.
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Jul 14th, 2002, 08:40 PM
#3
Thread Starter
^:^...ANGEL...^:^
This will help...
It gives an error at frm in the line above...
Cheers...
-
Jul 14th, 2002, 08:43 PM
#4
Hyperactive Member
D'Oh!! You need to use this:
VB Code:
If frm.name <> "frmMain" Then
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Jul 14th, 2002, 08:47 PM
#5
Thread Starter
^:^...ANGEL...^:^
hmmmm....
ThX Bill,
that one is solved...
another problem...
It unloads the frmMain aswell...why...???
VB Code:
Private Sub cmdBack_Click()
frmMain.Show
Dim frm As Form
For Each frm In Forms
If frm.Name <> "frmMain" Then
Unload frm
Set frm = Nothing
End If
Next frm
End Sub
Cheers...
-
Jul 14th, 2002, 09:11 PM
#6
Hyperactive Member
Hey,
I just tested your code in my app, and it works perfectly, it closes all the windows i have open, except for frmMain. The only reason i can think of for you main form closing as well is that it isn't call frmMain. When you do the name comparison it is case sensitive. Check you main form name and make sure its the same as the name in the if statement.
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Jul 14th, 2002, 09:17 PM
#7
Thread Starter
^:^...ANGEL...^:^
hmmmm....
thats right bill,
Your computer does the right thing and that code was working when i left office on friday night and when i come today, magic of microsoft...it doesn't work...
I am dead sure that its called frmMain and the case i have used is right but can't figure it out whats going on...
-
Jul 14th, 2002, 09:24 PM
#8
Not sure on this but you may want to try:
VB Code:
If frm.Name Is Not frmMain Then
-
Jul 14th, 2002, 09:31 PM
#9
Thread Starter
^:^...ANGEL...^:^
hmmmm....
ThX Edneeis,
but it gives a type mismatch error at 'Not' from the code u posted...
Cheers...
-
Jul 14th, 2002, 09:34 PM
#10
Frenzied Member
Try this:
Give frmMain a special tag (like 25360) and use:
VB Code:
Private Sub cmdBack_Click()
frmMain.Show
Dim frm As Form
For Each frm In Forms
If frm.tag <> 25360 Then
Unload frm
Set frm = Nothing
End If
Next frm
End Sub
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
Jul 14th, 2002, 09:38 PM
#11
Hyperactive Member
Yeah Wrack. I had a similar prob the other day. I had a major error that appeared in my app. Spent 2 days looking for a cause and couldn't find one. Then the other day i tried to show someone the problem and it didn't occur. Hasn't reappeared either. I hadn't done a thing to the code but. . . .
But thats Microsoft products
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Jul 14th, 2002, 09:42 PM
#12
-
Jul 14th, 2002, 09:42 PM
#13
Thread Starter
^:^...ANGEL...^:^
ThankX
Microbasic, Bill for your prompt response but its working now and I haven't done anything to it...
I will post this again if the problem reappears...
Cheers...
-
Jul 14th, 2002, 11:22 PM
#14
Thread Starter
^:^...ANGEL...^:^
mesa back...
the problem is back again...how do i get rid of it...
I am trying to work it out since 4 hours and its pain in a*** and my boss is really pissed of because of no constructive work...
Cheers...
-
Jul 14th, 2002, 11:33 PM
#15
The picture isn't missing
VB Code:
frmmain.Show
Dim frm As Form
For Each frm In Forms
If frm.Name <> frmmain.Name Then 'changed frmMain to frmMain.Name, because you are comparing NAMEs, not FORMS
Unload frm
Set frm = Nothing
End If
Next frm
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jul 14th, 2002, 11:39 PM
#16
Thread Starter
^:^...ANGEL...^:^
noop...
same thing...it unloads all form including frmMain...
any more ideas...
Cheers...
-
Jul 14th, 2002, 11:49 PM
#17
The picture isn't missing
i just tried it. it works. check all your form unloads and see if you are doing anything bad there.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jul 14th, 2002, 11:55 PM
#18
Thread Starter
^:^...ANGEL...^:^
it was working b4...
ThX buggy but it was working completely allright b4 i went to lunch and I came back and now its not working...
I am sure that I am not doing anything bad...
Cheers...
-
Jul 14th, 2002, 11:57 PM
#19
The picture isn't missing
this works for me, so run it and see if it works for you.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jul 15th, 2002, 12:00 AM
#20
PowerPoster
Wrack, show us your whole code. Everything that is in that Sub.
If that is everything then i dont know what the deal is becasue i just tried and it works fine.
Also, look in your other forms Unload_Events...Is it possible you are closing the FrmMain in one of those events?
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Jul 15th, 2002, 12:02 AM
#21
Thread Starter
^:^...ANGEL...^:^
hmmm..
Your code works fine and I copied my code to your project and it works fine...
But why doesn't it work on my project...I have got exactly the same thing but I can't understand what the h*** it doesn't work on my prokect...
hope someone has a same problem and they can help me...
-
Jul 15th, 2002, 12:04 AM
#22
The picture isn't missing
post all your unload subs from all your forms. did you even check?
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jul 15th, 2002, 12:14 AM
#23
Thread Starter
^:^...ANGEL...^:^
Here it goes...
VB Code:
' This same code works in other FORMS but not this one
Private Sub cmdBack_Click()
frmMain.Show
Dim frm As Form
For Each frm In Forms
If frm.Name <> "frmMain" Then
Unload frm
Set frm = Nothing
End If
Next frm
End Sub
Private Sub cmdSupport_Click()
Call JumpBetweenForms
Call frmMain.cmdSupport_Click
End Sub
Private Sub JumpBetweenForms()
Dim frm As Form
For Each frm In Forms
If frm.Name <> "frmMain" Then
Unload frm
Set frm = Nothing
End If
Next frm
End Sub
'This is frmMain.cmdSupport_Click event
Public Sub cmdSupport_Click()
On Error GoTo ErrorHandler
Set cnnMain = New ADODB.Connection
cnnMain.CursorLocation = adUseClient
Call modError.ADO_Error
Screen.MousePointer = vbHourglass
frmSupport.Show
Me.Hide
Screen.MousePointer = vbNormal
ErrorHandler:
If Err.Number = -2147467259 Or Err.Number = -2147217865 Then
Dim intYesNo As Integer
intYesNo = MsgBox("System could not find DATABASE or DATABASE format is incorrect. Please locate it and press Apply Changes button. Would you like to locate it.", vbCritical + vbYesNo, "Austrak Licencing Management System")
If intYesNo = 6 Then
Me.Hide
frmAdmin.Show
Else
End
End If
End If
End Sub
-
Jul 15th, 2002, 12:26 AM
#24
The picture isn't missing
i thought you said you changed
If frm.Name <> "frmMain" Then
to
If frm.Name <> frmMain.Name Then
how many forms do you have? post all your unload code like i said.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jul 15th, 2002, 12:28 AM
#25
Thread Starter
^:^...ANGEL...^:^
it doesn't matter...
I tries that way aswell and in all other forms its just "frmMain" not frmMain.Name
I thought that doesn't make any difference as it works in all other forms...
Cheers...
-
Jul 15th, 2002, 01:00 AM
#26
The picture isn't missing
so did you check your ALL unload code? you never actually said you did you just assumed it would be ok. make sure you don't have any frmMain.Unload or something that would unload all forms.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jul 15th, 2002, 01:08 AM
#27
Thread Starter
^:^...ANGEL...^:^
I checked all...
I checked everywhere and couldn't find anything which unloads the frmMain...
Cheers...
-
Jul 15th, 2002, 02:50 AM
#28
Frenzied Member
I have had similar, though not identical, problems. Try using
VB Code:
frmmain.Show
Dim frm As Form
For Each frm In Forms
If frm.Name <> frmmain.Name Then
'Unload frm --> Do not use this
Set frm = Nothing
End If
Next frm
See if that sort of helps.
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Jul 15th, 2002, 03:21 AM
#29
Fanatic Member
Can you not step through the execution (F8) and see at what point it unloads frmMain?
Martin J Wallace (Slaine)
-
Jul 15th, 2002, 03:31 AM
#30
PowerPoster
You sure it is unloaded and not just hidden? I see a few .Hide 's in there... also a bit of spaghetti coding eg frmMain.cmdSupport_Click.
Do a global search for Unload statements or Nothing and Rem them all out and then add back one at a time. Maybe u are unloading frm Main in the unload event of another form
-
Jul 15th, 2002, 05:10 AM
#31
Arrr...Sod it! Goodbye Mr Hodgeheg...*sob*
Use:
VB Code:
If Not frm Is frmMain Then
That will do the trick as it's checking to see if frm is the same object as frmMain...simple. Try it, it will work...
Woka
-
Jul 15th, 2002, 05:18 AM
#32
Arrr...Sod it! Goodbye Mr Hodgeheg...*sob*
Use:
VB Code:
If Not frm Is frmMain Then
That will do the trick as it's checking to see if frm is the same object as frmMain...simple. Try it, it will work...
Woka
-
Jul 15th, 2002, 09:23 PM
#33
Thread Starter
^:^...ANGEL...^:^
hmmmm....
Thank you very much for your help Slaine...
I step through it and found that while unloading all forms except frmMain, say for example I am in frmClient then the Form_Unload event of frmClient had a code to unload all forms and so when it was trying to unlaod all forms except frmMain it was invoking frmClient's Unload event and which was ultimately the cause of trouble...
Appreciate all of your reply and thankx again to make me solve that problem in 1 day...
Cheers...
-
Jul 15th, 2002, 09:29 PM
#34
The picture isn't missing
........ you know i DID tell you 3 times to check ALL your form's unload subs....
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jul 15th, 2002, 09:38 PM
#35
Thread Starter
^:^...ANGEL...^:^
ThankX
BUGGY,
But I was looking for a code like this...
and I search through whole code but can't find it obvously because the code was like this...
VB Code:
Dim frm As Form
For Each frm In Forms
Unload frm
Set frm = Nothing
Next frm
I learned a huge lesson today...listen to BUGGY... ...
Cheers...
-
Jul 16th, 2002, 12:18 AM
#36
-
Jul 16th, 2002, 12:21 AM
#37
The picture isn't missing
Originally posted by Arc
Listen to buggy? If you read the thread you will see that i was the one that suggested you look at all the unload subs of the other forms.
But that's ok, I'm used to doing all the work and getting no credit
look 3 replies above yourse
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jul 16th, 2002, 12:23 AM
#38
Thread Starter
^:^...ANGEL...^:^
hmmmm....
if u see the reply...I am kicking...
but THX to all...
-
Jul 16th, 2002, 12:51 AM
#39
PowerPoster
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

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
|