|
-
Jul 5th, 2000, 11:04 PM
#1
Thread Starter
Fanatic Member
I'm trying to get from the main form to the final form of my program which gives the user results from their quiz. The problem I'm having is that it loads the Summary but then it goes back to the code from the Quiz. Here's my code to get me from the Quiz form to the Summary form:
frmSummary.Show
frmSummary.Top = frmQuiz.Top
frmSummary.Left = frmQuiz.Left
Unload frmQuiz
The Summary code is very simple:
Private Sub Form_Load()
lblTally.Caption = " " & Correct & " out of " & (QAsked + 1) & Chr$(13) & " Your Score:" & Int((Correct / (QAsked + 1)) * 100) & "%"
End Sub
Private Sub cmdSubmit_Click()
End
End Sub
But instead of waiting for the Submit Click (which has been titled "Exit Program", it goes right back into the Quiz form code. Can anyone tell me what the heck is going on?
mikeycorn
-
Jul 5th, 2000, 11:09 PM
#2
Any time you reference a visible control on an unloaded form it is loaded again. Try just hiding the form until EOJ and then unloading it.
-
Jul 5th, 2000, 11:09 PM
#3
Hyperactive Member
um
did u by mistake put "frmquiz.show" in the unload event of frmsummary?
-
Jul 5th, 2000, 11:09 PM
#4
try this..
it should work...
Code:
Private Sub cmdSubmit_Click()
Dim F As Form
For Each F In Forms
Unload F
Next F
End Sub
-
Jul 6th, 2000, 01:26 AM
#5
Hyperactive Member
All good solutions
But in case you were looking for a much simpler answer
From the example, it appears you are be calling the code form within a Sub on the frmQuiz (or other) form. Also, I presume there is code following the "Unload frmQuiz" statement?
In this case,
'frmQuiz is already running and user hits a button to get to summary form
frmSummary.Show
' here, the frmSummary is created and displayed
' I would use load frmSummary, then set the top and left, then frmSummary.show. Looks nicer 
frmSummary.Top = frmQuiz.Top
frmSummary.Left = frmQuiz.Left
' frmSummary's position is adjusted
Unload frmQuiz
' Attempt to unload frmQuiz should work
If you put a trace message in frmQuiz_Unload, you will see that the Unload frmQuiz works.
NExt, as I presumed there to be another statement, the frm summary is still loaded, but perhaps now in the background, and the calling form (perhaps frmQuiz, or some code that eventually references a frmQuiz) causes a new frmQuiz to be created.
Short answer in solving your immediate problem is to use Hide instead of unload, OR on the frmSummary.Show line, use frmSummary.Show vbModal,Me which will force the system to wait for the frmSummary form to close before running the calling Sub's next statment.
Hence the reason I would Load the frmSummary, then change the top, left attributes, THEN I would either unload or hide the frmQuiz, and finally show the frmSummary.
Code:
' in a nutshell
Load frmSummary
frmSummary.Top = frmQuiz.Top
frmSummary.Left = frmQuiz.Left
frmQuiz.Hide
frmSummary.Show frmSummary, vbModal, Me
I hope this helps in additoon to the previous replies
Paul Lewis
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
|