Results 1 to 4 of 4

Thread: Run time error 340?

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Quantico, VA, USA
    Posts
    41

    Question

    The error message occurs and tells me that control element '0' doesn't exist. The problem is, the control elements are all *design time* creations, so they should be there. I thought it was because I was calling a user defined function on the form before the form was loaded, so I threw in a DoEvents to allow the form some time to catch up loading. That wasn't it. I tried using the form.Refresh method on the form, and I'm not sure if that worked or not. Someone else tells me they get the message, but I no longer do ( the project is shared). Does anyone have any good explanation of what's going on here????

    Chuck
    To err is human, but to apologize frequently is embarassing.

  2. #2

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Quantico, VA, USA
    Posts
    41
    I call the procedure from another function on another form. See, here's how it works:

    'on frmMain
    Private Sub mnuList_Click()
    Dim mList

    'here is where I load the form by calling the function
    mList = frmOne.BuildList(Id)

    End Sub

    'on frmOne
    Public Function BuildList(Id As String) As Boolean

    Me.Caption = "Build"

    '**************************
    '*HERE'S WHERE IT BLOWS UP*
    '**************************

    cmdOptions(0).Caption = "BUILD"

    '***********************************************
    '* IT TELLS ME THAT cmdOptions(0) DOESN'T EXIST*
    '* SOMETIMES... *
    '***********************************************

    '***********************************************
    '* KEEP IN MIND THAT A LOT MORE HAPPENS HERE. *
    '* THE ONLY THING THAT EVER HAPPENS TO THE *
    '* BUTTON IS THAT IT IS MADE INVISIBLE. *
    '***********************************************

    End Function

    Nothing else happens to that button. It is the first one in the list of things to do, so maybe the button sometimes isn't loaded quick enough?

    -chuck
    To err is human, but to apologize frequently is embarassing.

  3. #3
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    I don't think that's a problem, becuz all control's load before code begins executing.

    The problem is somewhere, but where, I do not know. Try looking REAL hard through all your code etc and if all else fails, heh, write a test prog with just that code/controls and get it to work, then Cut & Paste over to your project.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Quantico, VA, USA
    Posts
    41
    Thanks to all who replied. I'm not sure, but I think the code problem had something to do with multitasking capabilities of NT. mlewis was right in that the controls should load before any code executes. but i think when the code is actually executed, some strands execute simultaneously (with checks of course to see if these strands affect each other). Here's how I fixed it, in case anyone else has this problem:

    instead of just calling the method of the form to load it, ie. formOne.BuildList, do this-

    'this will start the create a new instance
    dim frmTwo as new formOne
    'allow any events to fire that need to
    doevents
    'finally call method
    frmTwo.BuildList

    the funny thing is that this error didn't start to happen until after a data access routine (the two shouldn't be related in the least). again, thanks to all who responded.

    -chuck
    To err is human, but to apologize frequently is embarassing.

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