473,587 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to save changes to form property in VBA?

I'm trying to set up a "preference s 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.RunComma nd acCmdSave" do the trick?
For Each varF In Array("frm0", "frm1", "frm2", "frm3")
If DLookup(varF, "tblColors" ) = -1 Then ' this form selected for new
Forms(varF).Det ail.BackColor = DLookup("Color" , "tblColors" )
DoCmd.Save acForm, varF
End If
DoCmd.RunComman d acCmdSave
Nov 12 '05 #1
4 18744
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

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:=acH idden
Forms(varF).Det ail.BackColor = lngC
Select Case varF
Case "frm0"
With Forms("frm0")
.lstAddress.Bac kColor = lngC
.NextAppt.BackC olor = lngC
.txtTxCt.BackCo lor = lngC
.cbxCategory.Ba ckColor = lngC
.txtFilterDispl ay.BackColor = lngC
.txtRecordsFoun d.BackColor = lngC
.txtFindEid.Bac kColor = lngC
.Entity_ID.Back Color = lngC
End With
DoCmd.Save acForm, varF
DoCmd.Close acForm, varF
DoCmd.OpenForm "frm0Addres s", View:=acDesign,
WindowMode:=acH idden
Forms("frm0Addr ess").AddressSt ring.BackColor = lngC
Forms("frm0Addr ess").Detail.Ba ckColor = lngC
DoCmd.Save acForm, "frm0Addres s"
DoCmd.Close acForm, "frm0Addres s"
Case "frm1"
With Forms("frm1")
.txtTotalCriter ia.BackColor = lngC
.txtTotalHeader .BackColor = lngC
.txtQ1Title.Bac kColor = lngC
.txtQ2Title.Bac kColor = lngC
.txtQ3Title.Bac kColor = lngC
.txtQ4Title.Bac kColor = lngC
.txtTotalPendin g.BackColor = lngC
.cbxMonthPendin g.BackColor = lngC
.txtMonthPendin g.BackColor = lngC
.txtNameHeader. BackColor = lngC
End With
DoCmd.Save acForm, varF
DoCmd.Close acForm, varF
Case "frm2"
With Forms("frm2")
.txtTotalPendin g.BackColor = lngC
.cbxMonthPendin g.BackColor = lngC
.txtMonthPendin g.BackColor = lngC
End With
DoCmd.Save acForm, varF
DoCmd.Close acForm, varF
Case "frm3"
With Forms("frm3")
.TypeTotalsStri ng.BackColor = lngC
.txtQuarterStri ng.BackColor = lngC
.TypeTotalsStri ng.BackColor = lngC
.txtQ1.BackColo r = lngC
.txtQ2.BackColo r = lngC
.txtQ3.BackColo r = lngC
.txtQ4.BackColo r = lngC
End With
DoCmd.Save acForm, varF
DoCmd.Close acForm, varF
End Select
DoCmd.OpenForm varF
End If
Exit Sub
Select Case Err.Number
Case Else
modHandler.LogE rr ("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

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 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
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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 reflect the nature of the selection. Now for some reason there is a particular view of this form and subforms in which there is a selparate filtered...
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 more changes to a field can be saved at once? Thanks!
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 MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then 'do nothing Else
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 information. sample.aspx contents: <form id="Form1" method="post" runat="server"> <asp:TextBox id="TextBox1" runat="server" Width="560px"...
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 appreaciated. Thanks. Code below: Imports System.Data.OleDb Public Class Form2 Inherits System.Windows.Forms.Form #Region " Windows Form...
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"/> </configSections> <AdminUIConfig name="Admin" caption="Administrator" captionLC="administrator">
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 Trail Option Compare Database Const cDQ As String = """" Sub AuditTrail(frm As Form, recordid As Control) 'Track changes to data. 'recordid...
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 these commands and they work perfect.
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 captions and formatting to match the user's locale. One thing that I commonly do is set the Format property of text boxes that display date/time values to...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.