Results 1 to 9 of 9

Thread: enable/focus in form_load

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    enable/focus in form_load

    VB Code:
    1. Combo0.Enabled = True
    2.     Combo13.Enabled = True
    3.     Combo0.RowSource = "01;02;03;04;05;06;07;08;09;10;11;12;"
    4.     Combo0.SetFocus
    5.     Combo0.Text = Format(Now, "mm")
    6.     Combo13.RowSource = Year(Now) - 1 & ";" & Year(Now) & ";" & Year(Now) + 1 & ";"
    7.     Combo13.SetFocus
    8.     Combo13.Text = Year(Now)
    9.     Display_Report.SetFocus
    10.     Combo0.Enabled = False
    11.     Combo13.Enabled = False

    There has to be a better way to do this. I want the form to start up with values in the combo boxes but I don't want them to be enables unless the user clicks a different option button.

    I had to do the setfocus enable/disable routine just to get it to work... unless there is a better way?!
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  2. #2
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    ...

    dont use the .Text property of a combo box.

    Code:
    Combo0.Text = Format(Now, "mm")
    becomes
    Code:
    Combo0 = Format(Now, "mm")

  3. #3

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Sweet... next question... I have 3 options in an option frame, but when I open the form and click on another option, it won't go to it. It will execute the code, but the option will not be selected.

    ??
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  4. #4
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    also

    get rid of the setfocus statements

  5. #5

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    I did that. I had to do it that way to get it to work the first time.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  6. #6
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    check the value of the frame you attached the options buttons to

    each option button should have its own value which is reflected in the Frame's value property

  7. #7
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    us the Wizard helps

    the wizard helps a lot when setting up options groups

  8. #8
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Omitting the default property (i.e. text) of a control when you reference it is also a little faster.

  9. #9

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    OK, well I got the stupid thing figured out. I was setting the focus to the option to get around the problem of the error I posted before. As soon as I took all those out, it worked fine
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

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