UserForm - Weird?

Discussion in 'AutoCAD' started by jbryant4, Oct 15, 2004.

  1. jbryant4

    jbryant4 Guest

    Having a really strange problem....I have a form. The name property of the form is frmSaddleEnd....It has a combobox named cboSad_boltdia...In the UserForm_Initialize() event, I fill the combobox like this.........

    cboSad_boltia.AddItem "1.0"
    cboSad_boltia.AddItem "1.5"
    etc.

    At one point this was working, however now when I run the program, I get the following error:

    Runtime error '424'
    Object required

    If I change the name of the UserForm_Initialize() event to frmSaddleEnd_Initialize(), the program runs, however the combobox is not filled???????

    As I said, this was working fine at one point....What could I have done to cause this behaviour...Makes no sense to me...
     
    jbryant4, Oct 15, 2004
    #1
  2. jbryant4

    Tim Riley Guest

    If you select dubug where does it take you? Also you might want to try using
    breakpoints and using F8 to step through your code.

    ~Tim Riley

    form is frmSaddleEnd....It has a combobox named cboSad_boltdia...In the
    UserForm_Initialize() event, I fill the combobox like this.........
    frmSaddleEnd_Initialize(), the program runs, however the combobox is not
    filled???????
    cause this behaviour...Makes no sense to me...
     
    Tim Riley, Oct 15, 2004
    #2
  3. jbryant4

    vb-Bla-Bla Guest

    <object>_Initialize event required that <object>_Load event has already
    loaded all OBJECT. At the debug/compile time it works fine because VB/VBA
    IDE keeps memory of all loaded objects from the first time. Normally you
    need to use <object>_Initialize event to change set some "module
    public/private properties", global/local variables AND NOT REFER TO ANY
    control. These usually loaded with <object>_Load event.
    Here are all events in sequence...

    Initialize
    Load
    Resize
    Activate
    Paint
    Deactivate
    QueryUnload
    Unload
    Terminate

    You can reference to controls and form object in Load or after Load event
    only.
     
    vb-Bla-Bla, Oct 16, 2004
    #3
  4. jbryant4

    jbryant4 Guest

    Thanks, but I do not understand a word you wrote.....If I start a new form, add a combobox, and use the USerForm_Inititalize event, to fill the combobox it works fine..As I stated my form was also working fine at some point.......When the initialize event is UserForm_Inititalize Debug will not even get to the point where the form is loaded (it crashes before that)....If I change it to frmSaddleEnd_Initialize the form loads, Debug reports no errors, however the combobox is not filled....Something sounds corrupt.
     
    jbryant4, Oct 18, 2004
    #4
  5. jbryant4

    user0 Guest

    Make sure to unload your form eah time you're finished with it and set it = nothing. This may give you the behavior you're looking for.
     
    user0, Oct 18, 2004
    #5
  6. jbryant4

    jbryant4 Guest

    I figured it out (needed anthoer set of eyes).....The combobox being filled in UserForm_Initialize needed the name of the form in front of the AddItem Call ......frmSaddleEnd.cboSad_boltdia.Additem "1", etc..........I find it weird that the form Events do not use the Form "Name" property in their definitions, but instead use UserForm_Click, UserForm_Initialize, etc......
     
    jbryant4, Oct 18, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.