i have some forms and some reports in an access application. Ok, this is what i have:
i have a form that adds a new file and then i have a form that closes a file. and then i have some reports that users will run that shows "active" files and that shows "closed" files. Once they open a new file it creates a record that has an "active" status. then sometime later they will close that file. Once they close the file it will get a status of "closed". But the problem is if they run a report with all active files by a particular attorney, it will show the active record even though it has been closed and has a "closed" status. what i need to be able to do is, once the file is closed to some how remove that record that had the "active" status so if the user run a report for a particular attorney with all active records it won't show the one that was closed too. i hope all of that make sense. Here is my code to close a file. I was thinking it needs to be done somewhere in this code:
Private Sub cmdCloseFile_Click()
On Error GoTo Err_cmdCloseFile_Click
Dim Result
Dim rst As ADODB.Recordset
Dim adocmd As ADODB.Command
sqlStmt = ""
Set adocmd = New ADODB.Command
Set rst = New ADODB.Recordset
With adocmd
.ActiveConnection = CurrentProject.Connection
.CommandType = adCmdText
.CommandText = "Select * from dbo_tbl_Files where Status = 'closed' and FileNo = " & Me.FileNo
End With
rst.CursorLocation = adUseClient
rst.Open adocmd, , adOpenStatic, adLockReadOnly
If rst.RecordCount > 0 Then
MsgBox "This File has already been closed.", vbCritical, "FileNo Confirmation"
Result = vbNo
DoCmd.Close
DoCmd.OpenForm "Legal Files Main"
Else
Result = MsgBox("Are you sure you want to close File No. " + Str$(Me.FileNo) + "?", vbYesNo, "Add File")
If Result = VbMsgBoxResult.vbNo Then
Me.Room = ""
Me.BoxNo = ""
Me.DateClosed = ""
DoCmd.Close
DoCmd.OpenForm "Legal Files Main"
End If
End If
rst.Close
Set rst = Nothing
Set adocmd = Nothing
If Result = vbNo Then
Exit Sub
End If
Dim rstFile As New ADODB.Recordset
Dim fld As ADODB.Field
Dim strField As String
rstFile.Open "dbo_tbl_Files", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rstFile.AddNew
rstFile!FileNo = Me.FileNo
rstFile!FileName = Me.FileName
rstFile!Dept = Me.Dept
rstFile!Room = Me.Room
rstFile!BoxNo = Me.BoxNo
rstFile!DateClosed = Me.DateClosed
rstFile!AttyID = Me.AttyID
rstFile!Description = Me.Description
rstFile!Status = "Closed"
rstFile.Update
rstFile.Close
MsgBox "File Successfully Closed."
Msg = "Do you want to close another file?"
Response = MsgBox(Msg, vbYesNo)
If Response = vbYes Then
DoCmd.Save
DoCmd.Close
DoCmd.OpenForm "Close File"
Else
DoCmd.Close
DoCmd.OpenForm "Legal Files Main"
End If
Exit_cmdCloseFile_Click:
Exit Sub
Err_cmdCloseFile_Click:
MsgBox Err.Description
Resume Exit_cmdCloseFile_Click
End Sub

i have a form that adds a new file and then i have a form that closes a file. and then i have some reports that users will run that shows "active" files and that shows "closed" files. Once they open a new file it creates a record that has an "active" status. then sometime later they will close that file. Once they close the file it will get a status of "closed". But the problem is if they run a report with all active files by a particular attorney, it will show the active record even though it has been closed and has a "closed" status. what i need to be able to do is, once the file is closed to some how remove that record that had the "active" status so if the user run a report for a particular attorney with all active records it won't show the one that was closed too. i hope all of that make sense. Here is my code to close a file. I was thinking it needs to be done somewhere in this code:
Private Sub cmdCloseFile_Click()
On Error GoTo Err_cmdCloseFile_Click
Dim Result
Dim rst As ADODB.Recordset
Dim adocmd As ADODB.Command
sqlStmt = ""
Set adocmd = New ADODB.Command
Set rst = New ADODB.Recordset
With adocmd
.ActiveConnection = CurrentProject.Connection
.CommandType = adCmdText
.CommandText = "Select * from dbo_tbl_Files where Status = 'closed' and FileNo = " & Me.FileNo
End With
rst.CursorLocation = adUseClient
rst.Open adocmd, , adOpenStatic, adLockReadOnly
If rst.RecordCount > 0 Then
MsgBox "This File has already been closed.", vbCritical, "FileNo Confirmation"
Result = vbNo
DoCmd.Close
DoCmd.OpenForm "Legal Files Main"
Else
Result = MsgBox("Are you sure you want to close File No. " + Str$(Me.FileNo) + "?", vbYesNo, "Add File")
If Result = VbMsgBoxResult.vbNo Then
Me.Room = ""
Me.BoxNo = ""
Me.DateClosed = ""
DoCmd.Close
DoCmd.OpenForm "Legal Files Main"
End If
End If
rst.Close
Set rst = Nothing
Set adocmd = Nothing
If Result = vbNo Then
Exit Sub
End If
Dim rstFile As New ADODB.Recordset
Dim fld As ADODB.Field
Dim strField As String
rstFile.Open "dbo_tbl_Files", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rstFile.AddNew
rstFile!FileNo = Me.FileNo
rstFile!FileName = Me.FileName
rstFile!Dept = Me.Dept
rstFile!Room = Me.Room
rstFile!BoxNo = Me.BoxNo
rstFile!DateClosed = Me.DateClosed
rstFile!AttyID = Me.AttyID
rstFile!Description = Me.Description
rstFile!Status = "Closed"
rstFile.Update
rstFile.Close
MsgBox "File Successfully Closed."
Msg = "Do you want to close another file?"
Response = MsgBox(Msg, vbYesNo)
If Response = vbYes Then
DoCmd.Save
DoCmd.Close
DoCmd.OpenForm "Close File"
Else
DoCmd.Close
DoCmd.OpenForm "Legal Files Main"
End If
Exit_cmdCloseFile_Click:
Exit Sub
Err_cmdCloseFile_Click:
MsgBox Err.Description
Resume Exit_cmdCloseFile_Click
End Sub
