Formatconditions not saving when form closed

Shaft

Registered User.
Local time
Today, 17:00
Joined
May 25, 2005
Messages
51
Hi,

I've written this subroutine that modifies 2 conditional formats when the 'Finish' button is clicked to the critrea entered in the form 'Control Panel'.
This works perfectly but when the form that the conditional formats are applied to is closed and reopened the conditional formats are reset. The only way I've found to make them stay is to open the conditional formating dialog box and clicking ok.

Code:
Private Sub cmdFinish_Click()
On Error GoTo Err_cmdFinish_Click

Forms![Control Panel].Refresh

Forms![Switchboard].Form![Engineer Overview]![SumOfTotal].FormatConditions(0).Modify acFieldValue, acBetween, DLookup("[cumltotallow]", "[Control Panel]"), DLookup("[cumltotalhigh]", "[Control Panel]")
Forms![Switchboard].Form![Engineer Overview]![SumOfTotal].FormatConditions(0).ForeColor = RGB(255, 128, 0)
Forms![Switchboard].Form![Engineer Overview]![SumOfTotal].FormatConditions(0).FontBold = True

Forms![Switchboard].Form![Engineer Overview]![SumOfTotal].FormatConditions(1).Modify acFieldValue, acGreaterThanOrEqual, DLookup("[cumltotalhigh]", "[Control Panel]")
Forms![Switchboard].Form![Engineer Overview]![SumOfTotal].FormatConditions(1).ForeColor = RGB(255, 0, 0)
Forms![Switchboard].Form![Engineer Overview]![SumOfTotal].FormatConditions(1).FontBold = True

DoCmd.Save acForm, "Switchboard"
DoCmd.Close

Exit_cmdFinish_Click:
    Exit Sub

Err_cmdFinish_Click:
    MsgBox Err.Description
    Resume Exit_cmdFinish_Click
    
End Sub
 
It looks to me like you are modifying the SubForm [Engineer Overview] not the form. How about: DoCmd.Save acForm, "Engineer Overview"

Spaces in names will give you unexpected grief some day. Use CamelFontNames or Under_Score_Names instead.
 
I've tried that already but it wont save because it's not open according to access.
 
I was afraid of that. Sorry but I'm out of ideas.
 
its not saving because its not open? how about something like this

Code:
DoCmd.Open acForm, "Engineer OverView"
Forms![Engineer Overview]![SumOfTotal].FormatConditions(0).Modify acFieldValue, acBetween, DLookup("[cumltotallow]", "[Control Panel]"), DLookup("[cumltotalhigh]", "[Control Panel]")
Forms![Engineer Overview]![SumOfTotal].FormatConditions(0).ForeColor = RGB(255, 128, 0)
Forms![Engineer Overview]![SumOfTotal].FormatConditions(0).FontBold = True

Forms![Engineer Overview]![SumOfTotal].FormatConditions(1).Modify acFieldValue, acGreaterThanOrEqual, DLookup("[cumltotalhigh]", "[Control Panel]")
Forms![Engineer Overview]![SumOfTotal].FormatConditions(1).ForeColor = RGB(255, 0, 0)
Forms![Engineer Overview]![SumOfTotal].FormatConditions(1).FontBold = True

DoCmd.Save acForm, "Engineer Overview"
DoCmd.Close

Im not entirely sure if it would work, as not that confident on access, but it seems the way to do it is to open the form as a form, apply the changes, then save it(removing the subform problem)
 
I don't think you can open a form when it is a subform. You can't have two instances of the forms/reports open.
A few things to try:

1) Save it using the subform object (probably won't work)
DoCmd.Save acForm, Forms("Switchboard").Engineer_Overview

2) Save it from within the subforms module space in VBA

3) Try changing the focus after you make the save. Call a set focus on the main form.


Additionally, you may have problem with it being the switchboard. If all else fails, store your settings in the windows registry, or create your own metadata table to store your settings.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom