Dont save a form after programmitic change

B

Bill

I dont want the standard message of "Save changes to form?" after I change
it's OrderBy property programatically, when I close the form. How do I do
this?
TIA
Bill
 
D

Dan Artuso

Hi,
Try putting this line of code in after you've changed the property:
DoCmd.Save acForm, "yourFormName"

I've not tested it but it should save the design changes.
 
B

Brendan Reynolds

The optional third, 'Save' argument of the DoCmd.Close method takes one of
three values, acSaveNo (don't save changes), acSavePrompt (ask the user, the
default) and acSaveYes (save the changes).

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
B

Bill

Thanks, but what event do I use. When the Close button is clicked, the event
deactivate and close dont fire until after the msgbox prompt to save
changes.
 
B

Brendan Reynolds

The Click event of the Close button.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
B

Bill

Great, thanks.....................but one question??? where is this event or
how do I create it.....(I need it to be from the forms close button (X))
 
B

Brendan Reynolds

I meant a custom command button. If you're not using one, then I'm not sure
where the prompt is coming from. When you close a form using the built-in
close button Access usually, in my experience, just goes ahead and saves the
Order By (and Filter) properties without prompting. One way to prevent this
from happening is to leave the Record Source property of the form empty in
design view, and set it in code in the Open event of the form ...

Private Sub Form_Open(Cancel As Integer)

Me.RecordSource = "tblTest"

End Sub

Access will not then attempt to save the Order By or Filter properties.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
J

John Vinson

Great, thanks.....................but one question??? where is this event or
how do I create it.....(I need it to be from the forms close button (X))

Open the Form in design view. Select View... Properties from the menu,
or right mouseclick the little square at the upper left and select
Properties. On the Event tab of the properties window, scroll down and
find the Close event. Click the ... icon by it and select Code
Builder.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top