By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,454 Members | 2,609 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,454 IT Pros & Developers. It's quick & easy.

Access 2007 Preventing Form Updates

P: 1
I am changing the FILTER, ORDERBY, and ORDERBYON attributes of an Access 2007 form. I have code tied to buttons on the form that resort and/or refilter the records of a datasource based on user selections.

When the form is closed, I am trying to wipe out any parameters that have been set in these attributes in order to try and put the form back in its original state, when these attributes were empty. See code I'm using below:

================================================== =======
Private Sub Form_Close()
On Error GoTo Err_Form_Close
'prevent unintentional form updates
Me.Filter = vbNullString
Me.OrderBy = vbNullString
Me.OrderByOn = False
DoCmd.Close acForm, Me.FormName, acSaveYes
Exit_Err_Form_Close:
Exit Sub

Err_Form_Close:
If (Err = 2501) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_Err_Form_Close
End Sub
================================================== =======

I have played with the "docmd". In the current code, I try to wipe out the values and save the form. I have also tried using ACSAVENO, with the thinking being that if I answered no, Access would not keep any of my changes. It doesn't seem to matter, because when I close the form and reopen in Design View, the last set of values from the form are in the ORDERBY and FILTER attributes.

I just added the err logic, in the hopes of making this work. But I thought I would see if someone could help while I try to figure this out. Any help would be GREATLY appreciated.
Jan 31 '08 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 446
Hi
I see your query has been around for 5 days and nobody has had a go!

I know what you mean about opening a form in design mode and seeing a filter or order-by string in the properties. This only seems to happen when you switch to Design mode from an open form. The last criteria seem to 'stick'.

I have not succeeded in removing them programmatically on the On_Close event. If you remove them manually (in design mode) then always close the form before opening in Design mode, they seem to remain clear.

However, even when they are not cleared they do not seem to have an effect on the form when Opened. Are they causing a problem ?

S7
Feb 5 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.