Need help removing a record

Unfortunately, I don't have Access 2007/2010 here at work, so I will have to take a look at it this evening if I have power (ice storm moving through this evening).
 
Since you are using linked tables from another source, the forms will not work properly for me.
 
Can you make a copy of the database, create a couple of similarly named tables and then import the data and post that?
 
ok, i'm no longer getting the write conflict error but it's not changing the status to closed.
here's the updated code:

Private Sub cmdCloseFile_Click()
On Error GoTo Err_cmdCloseFile_Click
Dim Result
Dim rst As ADODB.Recordset
Dim adocmd As ADODB.Command
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
Dim sqlstmt As String

rstFile.Open "dbo_tbl_Files", CurrentProject.Connection, adOpenKeyset, adLockOptimistic

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
 
ok i got it working now. i thank you from the bottom of my heart for all of your help!!!

i added the following code to the click event on the form itself.

Private Sub cmdUpdate_Click()
Me!Status = "Closed" ' Change the value
Me.Dirty = False ' Commit the change
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
End Sub
 
You're welcome. Good to hear that you were able to get it working. Good luck with your project
 

Users who are viewing this thread

Back
Top Bottom