Good Afternoon Everyone,
So i've been working on this Death record review form (unbound) so that many people can access it based on their hospital at the same time.
I'm having a problem with saving the values in the contols until I can update the batch at the end. I keep receiving an error message.
"Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record."
Could anyone help me out?
Below is the code I am using for the form.
So i've been working on this Death record review form (unbound) so that many people can access it based on their hospital at the same time.
I'm having a problem with saving the values in the contols until I can update the batch at the end. I keep receiving an error message.
"Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record."
Could anyone help me out?
Below is the code I am using for the form.
Code:
Option Compare Database
'this is the table I pull information from our SQL server from
Dim rs As ADODB.Recordset
'this is the actual table to write the information too
Dim rsDRR As ADODB.Recordset
Dim db As Database
Dim strConnection As String
Dim cnDRRTable As ADODB.Connection
Private Sub Form_Load()
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source = " & CurrentProject.path & "\MasterDBv2_DATA.mdb;"
Set db = CurrentDb
Set rs = New ADODB.Recordset
Set rsDRR = New ADODB.Recordset
Set cnDRRTable = New ADODB.Connection
cnDRRTable.Open strConnection
With rsDRR
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
.ActiveConnection = Nothing
'Open the recordset for the form
.Open "Select * From tblDeathRecordReview ", CurrentProject.Connection
End With
With rs
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
.ActiveConnection = Nothing
'Open the recordset for the form
.Open "Select * From dbo_DeathRecordReview WHERE Shortname = 'CMC' ORDER By CaseFileID DESC", CurrentProject.Connection
End With
Me.txtCaseFileID = rs!CaseFileID
Me.txtPatientName = rs!Donor
Me.txtAge = rs!Age
Me.txtReferOrganization = rs!Shortname
Me.txtUnit = rs!Unit
Me.txtOnVent = rs!ReferOnVent
Me.txtReferralClass = rs!Referral_Classification
Me.txtPotDonorType = rs!PotentialDonorType
Me.txtDeathDate = rs!DeathDate
Me.txtReferralDate = rs!ReferralDate
Me.txtTriggersMet = rs!ClinicalTriggersMet
Me.txtCauseOfDeath = rs!CauseOfDeath
Me.txtMOD = rs!MOD
Me.txtOPOCauseOfDeath = rs!OPOCauseOfDeath
Me.txtCircumOfDeath = rs!COD
Me.txtOrganOutcome = rs!OrganOutcome
Me.txtTissueOutcome = rs!TissueOutcome
Me.txtEyeOutcome = rs!EyeOutcome
Me.txtTimelyOrgan = rs!OrganTimely
Me.txtTimelyTissue = rs!TissueTimely
End Sub
Sub PopulateControlsOnForm()
'Use this function to populate controls on the DRR form
'with the current record from the navigation buttons
If Not rs.BOF And Not rs.EOF Then
Me.txtCaseFileID = rs!CaseFileID
Me.txtPatientName = rs!Donor
Me.txtAge = rs!Age
Me.txtReferOrganization = rs!Shortname
Me.txtUnit = rs!Unit
Me.txtOnVent = rs!ReferOnVent
Me.txtReferralClass = rs!Referral_Classification
Me.txtPotDonorType = rs!PotentialDonorType
Me.txtDeathDate = rs!DeathDate
Me.txtReferralDate = rs!ReferralDate
Me.txtTriggersMet = rs!ClinicalTriggersMet
Me.txtCauseOfDeath = rs!CauseOfDeath
Me.txtMOD = rs!MOD
Me.txtOPOCauseOfDeath = rs!OPOCauseOfDeath
Me.txtCircumOfDeath = rs!COD
Me.txtOrganOutcome = rs!OrganOutcome
Me.txtTissueOutcome = rs!TissueOutcome
Me.txtEyeOutcome = rs!EyeOutcome
Me.txtTimelyOrgan = rs!OrganTimely
Me.txtTimelyTissue = rs!TissueTimely
ElseIf rs.BOF Then
rs.MoveNext
ElseIf rs.EOF Then
rs.MovePrevious
End If
End Sub
Private Sub cmdPrevRecord_Click()
On Error GoTo Err_cmdPrevRecord_Click
Call SaveCurrentRecord
If Not rs.EOF Then
rs.MovePrevious
Call PopulateControlsOnForm
End If
Exit_cmdPrevRecord_Click:
Exit Sub
Err_cmdPrevRecord_Click:
MsgBox Err.Description
Resume Exit_cmdPrevRecord_Click
End Sub
Private Sub cmdNextRecord1_Click()
On Error GoTo Err_cmdNextRecord1_Click
Call SaveCurrentRecord
If Not rs.EOF Then
rs.MoveNext
Call PopulateControlsOnForm
Call ClearControlsOnForm
End If
Exit_cmdNextRecord1_Click:
Exit Sub
Err_cmdNextRecord1_Click:
MsgBox Err.Description
Resume Exit_cmdNextRecord1_Click
End Sub
Private Sub cmdLastRecord_Click()
On Error GoTo Err_cmdLastRecord_Click
Call SaveCurrentRecord
If Not rs.EOF Then
rs.MoveLast
Call PopulateControlsOnForm
End If
Exit_cmdLastRecord_Click:
Exit Sub
Err_cmdLastRecord_Click:
MsgBox Err.Description
Resume Exit_cmdLastRecord_Click
End Sub
Private Sub cmdFirstRecord_Click()
On Error GoTo Err_cmdFirstRecord_Click
Call SaveCurrentRecord
If Not rs.EOF Then
rs.MoveFirst
Call PopulateControlsOnForm
End If
Exit_cmdFirstRecord_Click:
Exit Sub
Err_cmdFirstRecord_Click:
MsgBox Err.Description
Resume Exit_cmdFirstRecord_Click
End Sub
'Here is where I am having the issue...
'All of the DRR* fields are the field names in the table.
'Thought this was suppose to hole the information until the connection
'was re-established?
Sub SaveCurrentRecord()
If Not rs.BOF And Not rs.EOF Then
rsDRR!DRRCaseFileID = Me.txtCaseFileID
rsDRR!DRRCompletedBy = Me.txtDRRCompletedBy
rsDRR!DRRDateCompleted = Me.dtDRRDateCompleted
rsDRR!DRRNeedFollowup = Me.ckDRRNeedFollowup
rsDRR!DRRComments = Me.mDRRComments
rsDRR!DRRMissed_EnteredTC = Me.ckMissedTC
rsDRR!DRRMissed_Comments = Me.txtMissedTCComment
rsDRR!DRRComplete = Me.ckDRRCompleted
End If
End Sub
Sub ClearControlsOnForm()
'Clear the input values
Me.txtCaseFileID = ""
Me.txtDRRCompletedBy = ""
Me.dtDRRDateCompleted = ""
Me.ckDRRNeedFollowup = ""
Me.mDRRComments = ""
Me.ckMissedTC = ""
Me.txtMissedTCComment = ""
Me.ckDRRCompleted = ""
End Sub
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
Call SaveCurrentRecord
rsDRR.UpdateBatch
Exit_cmdSave_Click:
Exit Sub
Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click
End Sub