• Setting a check box initial value in VBA code (Access 2003 / SP1)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Setting a check box initial value in VBA code (Access 2003 / SP1)

    Author
    Topic
    #414848

    I am finding it impossible in VBA code to set an initial value for an Access forms check box, that is, how the option box is to appear (checked or unchecked) when its parent form is Opened. My check box, which is not part of any option group, is otherwise working fine: As it is physically clicked, it is correctly passing True or False to its Me!CheckBox_Click event procedure.

    Since I don’t know how the box is to appear until its parent form is to be opened, I cannot pre-fill its Default Value property at design time; I must do it in code. I initialize all controls (all unbound) in the forms Form_Open event procedure.

    I’ve tried setting Me!CheckBox.DefaultValue to True, to “True”, and even to “=True”.
    I’ve also tried setting Me!CheckBox.Value to True, to “True”, and again even to “=True”.

    In all cases my code is ignored, and the check box is shown simply as grayed out. This all seems so simple; I’m following what the Help system is telling me to do. (I know, don’t get you started on that.) And I am having no trouble setting starting values to other kinds of controls (option groups, etc.) in that same Form_Load procedure.

    Can someone please tell me how to do this?

    Thank you,

    John

    Viewing 0 reply threads
    Author
    Replies
    • #923612

      Instead of the On Open event, try the On Load event of the form.

      • #923614

        As you suggested I moved Me!CheckBox.DefaultValue = True to the Form_Load event. It worked beautifully. Who would have known?

        Thank you for your help,

        John

        • #923617

          On Open occurs early, when the form is opened and before the first record is displayed. On Load occurs later, when the records are being displayed.

    Viewing 0 reply threads
    Reply To: Reply #923612 in Setting a check box initial value in VBA code (Access 2003 / SP1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel