472,133 Members | 1,071 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

How to save changes to form property in VBA?

I'm trying to set up a "preferences form" where users can choose from a few
different pre-defined colors. The color numbers and form names are saved in
tblColors. The below code changes the form backcolor no problem, but the colors
go back to what they were before if I close and reopen the database. How to I
save the changes? Shouldn't "DoCmd.RunCommand acCmdSave" do the trick?
For Each varF In Array("frm0", "frm1", "frm2", "frm3")
If DLookup(varF, "tblColors") = -1 Then ' this form selected for new
color
Forms(varF).Detail.BackColor = DLookup("Color", "tblColors")
DoCmd.Save acForm, varF
End If
Next
DoCmd.RunCommand acCmdSave
Nov 12 '05 #1
4 18464
You have to open the form in design mode to do this. if you've
secured your database, you might have to use DAO and open a workspace
with the admin's rights to change the colors.
Nov 12 '05 #2
> You have to open the form in design mode to do this.

ah yes... I see...

Here's the complete code if anyone is interested. I'm not sure if I need to
close the forms after opening them in Design mode - but it has not barfed on me
yet...

Public Sub Change()
On Error GoTo HandleErr
Dim lngC As Long
Dim varF As Variant
lngC = DLookup("Color", "tblColors")
For Each varF In Array("frm0", "frm1", "frm2", "frm3")
DoEvents 'this is important
If DLookup(varF, "tblColors") = -1 Then
DoCmd.OpenForm varF, View:=acDesign, WindowMode:=acHidden
Forms(varF).Detail.BackColor = lngC
Select Case varF
Case "frm0"
With Forms("frm0")
.lstAddress.BackColor = lngC
.NextAppt.BackColor = lngC
.txtTxCt.BackColor = lngC
.cbxCategory.BackColor = lngC
.txtFilterDisplay.BackColor = lngC
.txtRecordsFound.BackColor = lngC
.txtFindEid.BackColor = lngC
.Entity_ID.BackColor = lngC
End With
DoCmd.Save acForm, varF
DoCmd.Close acForm, varF
DoCmd.OpenForm "frm0Address", View:=acDesign,
WindowMode:=acHidden
Forms("frm0Address").AddressString.BackColor = lngC
Forms("frm0Address").Detail.BackColor = lngC
DoCmd.Save acForm, "frm0Address"
DoCmd.Close acForm, "frm0Address"
Case "frm1"
With Forms("frm1")
.txtTotalCriteria.BackColor = lngC
.txtTotalHeader.BackColor = lngC
.txtQ1Title.BackColor = lngC
.txtQ2Title.BackColor = lngC
.txtQ3Title.BackColor = lngC
.txtQ4Title.BackColor = lngC
.txtTotalPending.BackColor = lngC
.cbxMonthPending.BackColor = lngC
.txtMonthPending.BackColor = lngC
.txtNameHeader.BackColor = lngC
End With
DoCmd.Save acForm, varF
DoCmd.Close acForm, varF
Case "frm2"
With Forms("frm2")
.txtTotalPending.BackColor = lngC
.cbxMonthPending.BackColor = lngC
.txtMonthPending.BackColor = lngC
End With
DoCmd.Save acForm, varF
DoCmd.Close acForm, varF
Case "frm3"
With Forms("frm3")
.TypeTotalsString.BackColor = lngC
.txtQuarterString.BackColor = lngC
.TypeTotalsString.BackColor = lngC
.txtQ1.BackColor = lngC
.txtQ2.BackColor = lngC
.txtQ3.BackColor = lngC
.txtQ4.BackColor = lngC
End With
DoCmd.Save acForm, varF
DoCmd.Close acForm, varF
End Select
DoCmd.OpenForm varF
End If
Next
Exit_Here:
Exit Sub
HandleErr:
Select Case Err.Number
Case Else
modHandler.LogErr ("modColor"), ("Change")
Resume Next
End Select
End Sub
Nov 12 '05 #3
deko wrote:
You have to open the form in design mode to do this.


ah yes... I see...

Here's the complete code if anyone is interested. I'm not sure if I need to
close the forms after opening them in Design mode - but it has not barfed on me
yet...


I remember a programmer, I'll call him a binary (from Star Trek) that created an
app with lots of purple and greens in the background and yellow in the textboxes.
One day after leaving work this woman that had to use the app was complaining about
the headache she had from using the app. It just hit me that most likely the
programmer was color blind, wouldn't tell people about his defect, and subjected
people to "form hell". He was an idiot.

I watched another person using the app and she had trace tuirned on her mouse
pointer. As she'd move the mouse these trails would float across the screen. I
figured she was most likely stoned on magic mushrooms or lsd. Nobody, unless
stoned, would subject themselves to such punishment.

I've adoped the attitude that if someone wants a different color, go into Windows
Control panel and change the preferences there.

I also remember the sage words of a manager of mine years ago "Users will prefer an
ugly program that works over a pretty one that doesn't"
Nov 12 '05 #4
Comments: This message did not originate from the Sender address above.
It was remailed automatically by anonymizing remailer software.


This posting is yet another forgery.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jeremy Smith | last post: by
1 post views Thread by Shannon Richards | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.