Stop new record entry while filter is on??

  • Thread starter Thread starter Jens
  • Start date Start date
J

Jens

I have a form which we enter our job booking data into. To make it easier to
return to the correct record to update the data I have added a command button
to filter the form by Job Number (primary Key). My problem is that one of my
employees keeps updating his data then tries to enter a new record without
turning of the filter.
He then gets alll sorts of errors. Is thier any way I can stop a new record
being added while the filter is turned on??
 
Jens said:
I have a form which we enter our job booking data into. To make it
easier to return to the correct record to update the data I have
added a command button to filter the form by Job Number (primary
Key). My problem is that one of my employees keeps updating his data
then tries to enter a new record without turning of the filter.
He then gets alll sorts of errors. Is thier any way I can stop a new
record being added while the filter is turned on??

Why does he get errors? There is nothing about having a filter applied that
should affect adding new records. In fact, a form in DataEntry mode (used
exclusively for adding new records) is just a form with a filter applied
that eliminates all existing records.
 
(...)
I have a form which we enter our job booking data into. To make it easier
to
return to the correct record to update the data I have added a command
button
to filter the form by Job Number (primary Key). My problem is that one of
my
employees keeps updating his data then tries to enter a new record without
turning of the filter.
He then gets alll sorts of errors. Is thier any way I can stop a new
record
being added while the filter is turned on??

After setting the filter (in any way) is called ApplyFilter event. Write a
procedure for the event:

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
Me.AllowAdditions = (ApplyType = 0)
End Sub

The new record will be available only after turning off the filter.

Krzysztof Pozorek
MVP, Poland
www.access.vis.pl
 
(...)
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
Me.AllowAdditions = (ApplyType = 0)
End Sub

The new record will be available only after turning off the filter.

If you're doing it through button click, write something like this:

Private Sub On_Click()
Me.Filter = "Id=13" 'for example
Me.FilterOn = True
Me.AllowAdditions = False
End Sub

Private Sub Off_Click()
Me.Filter = ""
Me.FilterOn = False
Me.AllowAdditions = True
End Sub

K.P.
 
Thanks worked straght away.

Krzysztof Pozorek said:
(...)

If you're doing it through button click, write something like this:

Private Sub On_Click()
Me.Filter = "Id=13" 'for example
Me.FilterOn = True
Me.AllowAdditions = False
End Sub

Private Sub Off_Click()
Me.Filter = ""
Me.FilterOn = False
Me.AllowAdditions = True
End Sub

K.P.
 
Jens said:
I have a form which we enter our job booking data into. To make it easier to
return to the correct record to update the data I have added a command button
to filter the form by Job Number (primary Key). My problem is that one of my
employees keeps updating his data then tries to enter a new record without
turning of the filter.
He then gets alll sorts of errors. Is thier any way I can stop a new record
being added while the filter is turned on??

What you could also do is add the autonumber ID of the record just
added to the filter clause. And continue doing so until the form is
closed.

Tony
--
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
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Back
Top