Saving caption of Label in form on button press
Posted on 2004-09-06
I have a form which is not based on any tables/queries etc, and is only for printing sections of reports.
The Report ID is taken from an underlying form, that's fine.
if a user selects checkboxes 1, 2 & 3 (i.e. they want to print the pages for Section1, Section2 & Section3) and clicks print, only those pages are printed. Great.
I have now added a new function that will save their default selection. I thought, instead of creating a new table to store the values, I would simply use VB to change the caption of a label to include a * if the corresponding checkbox (and report) should be selected by default...
Can I get it to do it? Can I hell!!!
Working with only one checkbox (untill it works correctly) I have:
Check01 is the checkbox for printing the "cover sheet"
Label01 is the label associated with Check01
Label01 has the caption "1 - Cover Sheet"
Behind a button which is labeled "Set as default" I have the following code:
Me.Label01.Caption = IIf(Me.Check01.Value = True, IIf(Right(Me.Label01.Caption, 1) = Chr(42), Me.Label01.Caption, Me.Label01.Caption & Chr(42)), IIf(Right(Me.Label01.Caption, 1) = Chr(42), Left(Me.Label01.Caption, Len(Me.Label01.Caption) - 1), Me.Label01.Caption))
DoCmd.Save acForm, "PrintSelection"
Notes (Things that do happen!!):
If the check box is ticked, and the button is pressed, the caption changes.
If I comment out the DoCmd.Save, save the form, close it and re open it, tick the check box, press the button and close the form, I am prompted to save. - The only alteration is the caption change to incluse a *
Anyone had the same problem, or is it just me?
Any help greatly appreciated - More points available if it's considered a difficult question