Results 1 to 13 of 13

Thread: You can't do that the form isn't loaded! (But it is) {sorta...} [Resolved...]

  1. #1

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774

    You can't do that the form isn't loaded! (But it is) {sorta...} [Resolved...]

    VB Code:
    1. Private Sub Form_Load()
    2. DoEvents
    3.    DoCmd.GoToRecord , , acFirst
    4.    DoCmd.GoToRecord , Me.Name, acLast   'this one errors
    5. 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.
    ?
    'What's this bit for anyway?
    For Jono

  2. #2
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548
    instead of the load event try using the activate event

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    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.

  4. #4

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    It would seem that although we may have had an answer - saidly this code does not run...

    VB Code:
    1. Private Sub Form_Activate()
    2.     MsgBox "Form Activates"
    3.     If FrmFirst = False Then
    4.         'Goto new record
    5.             DoCmd.GoToRecord , , acFirst
    6.             DoCmd.GoToRecord , , acLast
    7.         FrmFirst = True
    8.         MsgBox "Went to last! Honest"
    9.     End If
    10. End Sub
    11.  
    12. Private Sub Form_Current()
    13. 'Text24.SetFocus
    14. Text24.Value = ShowMeTotal(Job_link_ID.Value)
    15. End Sub
    16.  
    17. Private Sub Form_Load()
    18. FrmFirst = False
    19. DoEvents
    20. End Sub
    ?
    'What's this bit for anyway?
    For Jono

  5. #5
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    What the hell is:
    VB Code:
    1. 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

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    Are you getting error messages, or does the Ativate code just not occur? Can you confirm that the execution is entering the activate code?

  7. #7

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    Originally posted by Wokawidget
    What the hell is:
    VB Code:
    1. 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.
    ?
    'What's this bit for anyway?
    For Jono

  8. #8

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    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.
    ?
    'What's this bit for anyway?
    For Jono

  9. #9
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    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

  10. #10

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    Originally posted by Wokawidget
    Arrrrr...right.
    We are dealing with VBA

    VBA NOT = VB
    yes sorry I thought the difference was going to be neglagable in this case.

    An unbound control that acts as a menu on all forms (open him, close me) allows me to move around and no it fails compleatly.

    I have cracked operating word from access and have created queries and calculations that are frankly impressive. I have even created custom rounding procedures that are mathmatical art but I can not fatham this problem.

    I feel like a VB newbie
    ?
    'What's this bit for anyway?
    For Jono

  11. #11
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    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.

  12. #12

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    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.
    ?
    'What's this bit for anyway?
    For Jono

  13. #13
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    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
  •  



Click Here to Expand Forum to Full Width