Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save form changes with command button

Status
Not open for further replies.

bfamo

Technical User
Feb 16, 2006
132
NO
Hi,
A simple question :)

How can I save form changes (not record changes) with a command button?

Lets say I have a code that sets Me.Detail.BackColor=vbRed, and I want this change to be permanent.

I've tried the following, which does not work:

Code:
Private Sub btnChange_Click()
Me.Detail.BackColor = vbRed
DoCmd.Save acForm, "FrmName"
End Sub

Any suggestions?

thanks!!!
 
You can only save design changes in design view. If you have some properties you would like to change, you can store them in a table and then when the form opens, retrieve and set the property values.

Duane
Hook'D on Access
MS Access MVP
 
thanks dhookom!

The reason I ask is actually to try to work around a problem I have encountered.

I have a Form1 with three buttons that opens the same form, only in different data modes; acFormPropertySettings, acFormEdit and acFormReadOnly.

The problem is that when opening the form in ReadOnly, this actually changes the forms property settings PERMANENTLY!
If I open it in edit mode after read only, I'm not able to edit records. The database is not shared on the network or anything like that.

I have tried to replicate this problem in a test database outside my business database, and the test database handles switching between the different data modes just fine.

I have also tried running my business database in ACC2007 (without converting it), and that also works just fine.

This is a very strange problem.
Any suggestions as to how I could solve this is greatly appreceiated!! :)
 
How are ya bfamo . . .

When you close the common form be sure you don't save!
Code:
[blue]   DoCmd.Close acForm, "formname", [purple][b]acSaveNo[/b][/purple][/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
bfamo?

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Hi guys...

I've been doing some more testing.
I have been closing the form for each time I open it in different data modes. The buttons event goes like this:
Code:
DoCmd.OpenForm "Form2", , , "[ID]=forms!Form1.form![ID]", [b]acFormReadOnly '(or acFormEdit or acFormPropertySettings)[/b]

It seems like the forms design is saved when I run it in acFormReadOnly, without any code telling it to. Its very strange, because the exact same code works as it should in ACC2007.

I did try out your suggestion AceMan, and this took care of my problem! In stead of closing the form with av button, I put the same code in the Form_Close event:

Code:
DoCmd.Close , "Form2", acSaveNo

So, I guess I'm in the clear... Without really knowing why this problem occurs in the first place.

Thanks so much for the help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top