|
-
Jan 15th, 2004, 10:27 AM
#1
Thread Starter
Fanatic Member
You can't do that the form isn't loaded! (But it is) {sorta...} [Resolved...]
VB Code:
Private Sub Form_Load()
DoEvents
DoCmd.GoToRecord , , acFirst
DoCmd.GoToRecord , Me.Name, acLast 'this one errors
End Sub
The error message comes back saying "Form [name of form] is not open."
This form is also nested that is it is a sub form.
can any one tell me why this may be.
Last edited by Matt_T_hat; Jan 28th, 2004 at 11:30 AM.
-
Jan 15th, 2004, 10:44 AM
#2
Fanatic Member
instead of the load event try using the activate event
-
Jan 15th, 2004, 10:55 AM
#3
The form can be considered to be in an intermediate state during the Load event. Some things can be done, like changing labels, button captions, colors, and other style issues. Other things cannot be done, as you have found.
Moving the code to the Activate event can work, but there are issues you would have to consider. The biggest is probably that the Activate event will fire if you move focus away from the form and back to it, so you don't want initialization code to run then. The other issue, is that there is a flaw in the way the debugger directs Activate events if there are breakpoints in the code (not necessarily in the Activate code, just in some code). This flaw can cause the Activate event not to occur, or the Activate event for a totally different form (even an irrelevant one) to occur. Debugging with this problem can be difficult, since the behavior of the program with a breakpoint will be different from the behavior without a breakpoint.
Still, Activate is the way to go, but you might want to use a form scope boolean to ensure that the Activate code that should only run once, does only run once.
-
Jan 15th, 2004, 11:16 AM
#4
Thread Starter
Fanatic Member
It would seem that although we may have had an answer - saidly this code does not run...
VB Code:
Private Sub Form_Activate()
MsgBox "Form Activates"
If FrmFirst = False Then
'Goto new record
DoCmd.GoToRecord , , acFirst
DoCmd.GoToRecord , , acLast
FrmFirst = True
MsgBox "Went to last! Honest"
End If
End Sub
Private Sub Form_Current()
'Text24.SetFocus
Text24.Value = ShowMeTotal(Job_link_ID.Value)
End Sub
Private Sub Form_Load()
FrmFirst = False
DoEvents
End Sub
-
Jan 15th, 2004, 11:23 AM
#5
What the hell is:
VB Code:
Private Sub Form_Current()
???
Why doesn't the code run?
Are you SHOWING the form after it's loaded?
The form has to be visible for the active event to fire.
Woka
-
Jan 15th, 2004, 11:30 AM
#6
Are you getting error messages, or does the Ativate code just not occur? Can you confirm that the execution is entering the activate code?
-
Jan 15th, 2004, 11:31 AM
#7
Thread Starter
Fanatic Member
Originally posted by Wokawidget
What the hell is:
VB Code:
Private Sub Form_Current()
It's a VBa thing meaning when you get to a new record do this bit... don't ask me microsoft named the darn thing.
The form is a sub form on another form.
The main form is the only form open
when it opens the subform Load, current, (active) but this is not true the last one does not run and I CAN NOT get the damn thing to goto last record. we've been working on this stupid DB for a bl**dy year now. I just want to ship it off and write some games or something. 256+ days of no skiving off is very bad.
-
Jan 15th, 2004, 11:37 AM
#8
Thread Starter
Fanatic Member
Originally posted by Shaggy Hiker
Are you getting error messages, or does the Ativate code just not occur? Can you confirm that the execution is entering the activate code?
I put a msgbox in that doesn't happen.
-
Jan 15th, 2004, 11:39 AM
#9
Arrrrr...right.
We are dealing with VBA 
VBA NOT = VB
Very similar, but in some case VERY different.
Anyways, VBA sucks.
I am amazed the Activate event isn't firing...
Does it fire if you load 2 forms, and flick between them?
Woka
-
Jan 15th, 2004, 11:46 AM
#10
Thread Starter
Fanatic Member
-
Jan 15th, 2004, 03:54 PM
#11
Originally posted by Matt_T_hat
[BThe form is a sub form on another form.
The main form is the only form open
when it opens the subform Load, current, (active) but this is not true the last one does not run [/B]
I think you'll find that SubForms are limited to two events; On Enter() and On Exit().
Bruce.
-
Jan 28th, 2004, 10:28 AM
#12
Thread Starter
Fanatic Member
It turns out that subforms get run first
it would seem the fix is to re-think the order of logical events from scratch.
Thanks anyway guys.
-
Jan 28th, 2004, 10:44 AM
#13
Frenzied Member
why is [RESOLVED] such a hard thing to add?
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
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
|