Form switches to READ ONLY after filter (1 Viewer)

123dstreet

Registered User.
Local time
Today, 09:52
Joined
Apr 14, 2010
Messages
122
Hi All,

I have a continuous form based on a query (the query has 2 tables with 1 relationship, it's fairly basic).

The problem is sporadic, which means I can't figure out the trigger causing it, but after the user filters the query either by serial number, or customer, etc... the form will change to strictly read only. The only way to fix this is to close the form, and sometimes close the entire database.

Here is the code used to set the filters:

Code:
Private Sub Command75_Click()
On Error GoTo ExitError
DoCmd.ApplyFilter , "[Receive Date]Is Not Null AND [Return Date] Is Null"
ExitError:
    Exit Sub
End Sub

Private Sub Command45_Click()
On Error GoTo ExitError
    '-- Find RMA Numbers starting with ---
    Me.Filter = "[RMA #] Like" & "'" & Me.Text43 & "*" & "'"
    If IsNull([Text43]) = False Then Me.FilterOn = True Else Me.FilterOn = False
    SendKeys "+{Down}"
ExitError:
    Exit Sub
End Sub

Private Sub Command40_Click()
On Error GoTo ExitError
    '-- Find SN Numbers starting with ---
    Me.Filter = "[Serial Number] Like" & "'" & Me.Text38 & "*" & "'"
    If IsNull([Text38]) = False Then Me.FilterOn = True Else Me.FilterOn = False
    SendKeys "+{Down}"
ExitError:
    Exit Sub
End Sub

Here is the code to clear all the filters:

Code:
Private Sub Command76_Click()
On Error GoTo ExitError
Me.FilterOn = False
Me.Text38 = ""
Me.Text43 = ""
Me.Combo60 = ""
'DoCmd.ShowAllRecords
DoCmd.GoToRecord , , acLast
ExitError:
    Exit Sub
End Sub


I can filter, clear filter, filter again, etc. and the form is fine. But then the odd time, the form will switch over to read only. If anyone can see a reason why this might be happening your input will be greatly appreciated!

Sincerely,
D
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 17:52
Joined
Sep 12, 2006
Messages
15,640
try setting the filterstring to "" before setting the filter off

maybe command76 IS erroring. It shouldn't be, but you wouldn't notice if it did. I can't really think it makes a difference, though, but you never know.

fwiw, I never need to use any code to re-display all the records.
 

123dstreet

Registered User.
Local time
Today, 09:52
Joined
Apr 14, 2010
Messages
122
Hi and thanks for your reply!

I've changed the filter string to "" before turning off the filter.
I have discovered that when no records are returned for any of the filters, the form shows as 'filtered' and becomes read only, when I run the Command76 to clear it, the form goes back to normal - This is using Access 2007. The problem does not occur if results are returned by the filter.

My other user is on Access 2010, and it seems to switch to read only after trying any of the filters, no matter what, and clearing the filter doesn't help. The form needs to be closed, and then sometimes the whole database.

From what I can see, when the form is switched to read only, it happens as soon as the filter command is run, not when the filter is being cleared.

Any thoughts on that?
 

JHB

Have been here a while
Local time
Today, 18:52
Joined
Jun 17, 2012
Messages
7,732
I would comment out all errorhandling until the code runs okay, because the way you've it you'll never catch if there is an error.
Then you're missing a space after the "Like" keyword.
Code:
... Like" & "'" & Me.Text43
It should be:
Code:
... Like " & "'" & Me.Text43
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:52
Joined
May 7, 2009
Messages
19,229
is your form has this property Allow Addition to False.
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 02:52
Joined
Jan 20, 2009
Messages
12,851
It may be another manifestation of the bug I described here.
 

Users who are viewing this thread

Top Bottom