Bound Form With Filter - Close When No Records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Access 2003/Windows XP

I've got a bound form with a filter (STATUS<>'CLOSED'). The users will be
able to change the value of the STATUS column using a drop-down. Here is the
behavior I want:

1) When a user changes the status of a record to 'CLOSED', it disappears for
that person and they can't see it again.
2) If all records have a status of 'CLOSED', the form pops up a message and
automatically closes.

Here's where I'm at.

1) The users navigate using command buttons that go to the next or previous
record. I tried using code like this:

If txtSTATUS.Value = "CLOSED" Then
DoCmd.ReQuery
End If

DoCmd.GoToRecord , acNext

The problem is, the ReQuery method seems to take the form back to the first
record. I don't want that.

2) I tried putting something like this on the Form_Current event

Set RS = Me.RecordSet
If RS.RecordCount = 0 Then
DoCmd.Close Me.Name
End If

However, the "Close" command gives me an error - Type mistmatch. (???)

I know this is possible. Any pointers? Thanks.
 
For your option 2, your syntax is wrong to close the form:

DoCmd.Close acForm, Me.Name
 
Back
Top