473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 18717
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jeremy Smith | last post by:
I have a Access 2K2 db that is used on the network. I have a main form that dependant upon the selected option loads the appropriate subform. when it does this several label captions change to...
2
by: Joe | last post by:
I have a form which displays data in 3 related tables. I want to give the user a prompt to save changes when any field has been modfied on the form. Is there a easy way to do this so the 1 or...
2
by: icedgar | last post by:
am using the following script in the BeforeUpdate area of a main form. Private Sub Form_BeforeUpdate(Cancel As Integer) Dim strMsg As String strMsg = "Do you wish to save your changes?" If...
2
by: jason | last post by:
hello. i am just trying to save a TextBox.Text value to a database, but strangely, when the value is changed on the web form, the changes are not recognized in the event where i try to save the...
0
by: Patty05 | last post by:
I have a datagrid on a form that update properly when form loads. When the program runs and I type in/add a new row in the datagrid, it does not save the changes. Any help would be greatly...
1
by: Shannon Richards | last post by:
Hello All: I have implemented a custom configuration section in my app.config file as follows: <configSections> <section name="AdminUIConfig" type="TestMgr.UIConfigSection,TestMgr"/>...
2
by: rockdc1981 | last post by:
I dont it is possible to put this codes together.. I want to prompt the user to save the record and at the same time have a log of audit trail. the codes work out fine separately. Code for Audit...
2
by: Matuag | last post by:
Hi All, I want to create following command buttons on a Form which users can edit. Save ( Save Changes made) Cancel ( Undo data changes) Exit ( Close form) I am using Macros for each of...
5
by: nsbecker | last post by:
Hi - I've got an interesting one here: I've got an mdb file that some users run in Access 2003 and some in 2007. I have a Localize function that is called on the open of each form to set the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.