Hi,
I need help on a code that each time I add a new record it gives me an
error "Eithe EOF or BOF is true, or the current record has been
deleted. Requested operation requires a current record.
I have an unboud form that records all the objectives. User can put
more than one progress assessment code and comment for each objective.
I have a control on Objective form that opens up Progress assessment
form. The code behind this control is as follows:
On Error GoTo Err_Handler
Dim lngObjD_ID As Long
Dim strPublishedYea r As String
Dim strObjectiveDes cription As String
lngObjD_ID = Me.ObjD_ID.Valu e
strPublishedYea r = Forms!frm_MainM enuViewer.cbo_F Y.Value
strObjectiveDes cription = Me.Objective_De scription.Value
DoCmd.OpenForm "frm_DE_Objecti ve_Progress_Ass essment", acNormal
Forms!frm_DE_Ob jective_Progres s_Assessment.Ca ption = "Objective
Progress Assessment"
Forms!frm_DE_Ob jective_Progres s_Assessment.lb l_Objective_Des cription.Captio n
= " "
Forms!frm_DE_Ob jective_Progres s_Assessment.lb l_Published_Yea r.Caption =
" "
'''' 'Forms!frm_DE_O bjective_Progre ss_Assessment.O bjD_ID.Value
= ""
Forms!frm_DE_Ob jective_Progres s_Assessment.lb l_Objective_Des cription.Captio n
= strObjectiveDes cription
Forms!frm_DE_Ob jective_Progres s_Assessment.lb l_Published_Yea r.Caption =
strPublishedYea r
Forms!frm_DE_Ob jective_Progres s_Assessment.Ob jD_ID.Value =
lngObjD_ID
' ' ' Fill form
Forms!frm_DE_Ob jective_Progres s_Assessment.Fi ll_Form lngObjD_ID
Forms!frm_DE_Ob jective_Progres s_Assessment.Mo dal = True
Exit_Sub:
Exit Sub
Err_Handler:
Debug.Print Err.Description
Resume Exit_Sub
End Sub
Any time I add a new objective and add progress assessment I get the
above mentioned error. For all the existing objectives if I add a
progress assessment, the records save without any problem.
The code behind the progress Assessment form is as follows:
Public Sub Fill_Form(ByVal vlngObjD_ID As Long)
On Error GoTo Err_Handler
OpenConnection_ To_BE
'Dim rst As ADODB.Recordset
Dim fld As ADODB.Field
Dim strListItems As String
Dim strSQL As String
Dim sControlName As String
Set rst = GetElementsStat us(vlngObjD_ID)
With rst
Do While Not (rst.EOF)
Me(rst!Element & "_cbo_Element_C olor_Code").Val ue =
rst!Element_Col or_Code
Me(rst!Element & "_RSA_ID").Valu e = rst!RSA_ID
Me(rst!Element & "_Analysis").Va lue = rst!Analysis
If Not (IsNull(rst!Ana lysis)) Then
Me(rst!Element & "_Analysis").Co ntrolTipText =
Left(rst!Analys is, 250) & " ..."
Else
Me(rst!Element & "_Analysis").Co ntrolTipText = ""
End If
rst.MoveNext
Loop
End With
Exit_Sub:
Exit Sub
Err_Handler:
MsgBox Err.Description
Resume Exit_Sub
End Sub
Private Sub cmd_Close_Form_ Click()
On Error GoTo Err_cmd_Close_F orm_Click
With rst
rst.MoveFirst
Do While Not (rst.EOF)
rst!Element_Col or_Code = Me(rst!Element &
"_cbo_Element_C olor_Code").Val ue
'rst!RSA_ID = Me(rst!Element & "_RSA_ID").Valu e
rst!Analysis = Me(rst!Element & "_Analysis").Va lue
rst.MoveNext
Loop
End With
If MsgBox("Save all changes?", vbYesNo) = vbYes Then
rst.UpdateBatch
Else
rst.CancelBatch
End If
' End If
DoCmd.Close
Exit_cmd_Close_ Form_Click:
Exit Sub
Err_cmd_Close_F orm_Click:
MsgBox Err.Description
Resume Exit_cmd_Close_ Form_Click
End Sub
I am failing to understand why on entering a new objective and then
entering the progress assessment for this new objective gives me an
error.
Any help would be appreciated.