Allow User to change default checkbox values

SyntaxSocialist

Registered User.
Local time
Today, 13:06
Joined
Apr 18, 2013
Messages
109
Ok, I've got a form (frmEdit) that allows users to search tblMain for records using a bunch of unbound controls and a dynamically created SQL statement. Search results are displayed in a subform (subMain), and the current record in the subform is displayed in a set of bound controls on frmEdit.

Now the important bit: There is a set of unbound checkboxes on my form that allow the user to change which fields are visible in subMain. This is accomplished by the following:
Code:
Private Sub chkName_AfterUpdate()

    If Me.chkName = 0 Then
        Me.subMain.Form.CorrespondingField.ColumnHidden = True
    Else
        Me.subMain.Form.CorrespondingField.ColumnHidden = False
    End If
    
End Sub

Certain fields are visible by default, but the user may want to change which fields those are. Here's what I've done so far to accomplish this:
  • Created a button (btnChangeDefaults) that opens a form (frmChangeDefaults)
  • Put checkboxes for each table field on frmChangeDefaults
  • Put a "Cancel" button (btnCancel)* and "Done" button (btnDone)** on frmChangeDefaults.
*btnCancel just closes frmChangeDefaults without making any changes to frmChangeDefaults or frmEdit
**btnDone changes Forms.frmEdit.Form.chkName.DefaultValue to Me.CorrespondingCheckBox.Value and then closes frmChangeDefaults

This all seems to work quite well, actually. Debugging confirms that the default values of the checkboxes on frmEdit are indeed changed when I click btnDone. But when I close frmEdit and re-open it, the default values return to what they were prior. AUGH! This happens even when:
  • I close frmEdit using DoCmd.Close acForm, "frmEdit", acSaveYes
  • I close frmEdit after using DoCmd.Save acForm, "FrmEdit"
  • I save frmEdit manually by right-clicking and pressing save

What am I missing here?:banghead:
 
Because the default value is set in design mode you need to save the form whilst it's in design mode.
Alternatively you could use database properties or a table to store the values then you wouldn't have to worry about changing the design of the form.
 
Because the default value is set in design mode you need to save the form whilst it's in design mode.
Alternatively you could use database properties or a table to store the values then you wouldn't have to worry about changing the design of the form.

Thanks so much! Sorry for the delay; I wanted to see if it would work first. It's going to take a little more work yet, but the solution of keeping the default values in a table looks like it'll do the trick. Just rather more complicated than I would have liked :P
 

Users who are viewing this thread

Back
Top Bottom