FindRecord & Bookmark work in debug but not realtime (1 Viewer)

kcnewheart

New member
Local time
Today, 15:06
Joined
Jul 30, 2016
Messages
3
I have a QA evaluation main form with a subform that contains multiple records associated with the evaluation displayed on the main form via an evaluation number (master/child). When the rating is changed in the current record on the subform, some fields are affected on the main form. After processing the changes, I want the record that was updated by the user on the subform to be the record that is displayed. That's where I'm having a problem.

I have tried a bookmark and I have tried a DoCmd.FindRecord. Both work in debug (I get exactly what I want), but not in realtime. The code processes with no error and indication that it's not working, except that at the final display, it is reset to the first record in the set.

Below is the code I'm currently using (the FindRecord). I've commented out the bookmark code but including it so you can see what I've tried. Also, I have checked the Data Entry properties for the main & subform Form types - set to No.

Help?? And yes, I'm a relative newbie, so be kind...

Code:
Private Sub QRating_AfterUpdate()
'This routine is called when the user updates the Rating for a question in the evaluation responses.
     Dim rcdSet As DAO.Recordset
    Dim varBookMark As Variant
    
    Dim QNum As String
    Dim EvalNum As Long
    
    'Save the question number for the current record to go back to it when the form is refreshed
    QNum = Me.QNmbr
    'Save the evaluation number to search for NCIs and warnings
    EvalNum = Me.EvalNmbr
    
    'Display the Response Date for the questions/records that indicate a non-conformity
    If Me.QRating = "Non-Conformity" Then
        Me.lblQDate.Visible = True
        Me.QDate.Visible = True
    Else
        Me.lblQDate.Visible = False
        Me.QDate.Visible = False
    End If
           
    'Refresh the form and database so that Rating totals can be assessed/posted on parent form
    If Me.Dirty Then Me.Dirty = False
    Me.Refresh
        
    'Search the current evaluation's QA responess for any NCIs or Warnings
    NCI_Cnt = RecordCount1Str1Lng("tblPROCESS_RESPONSES", "QRating", "Non-Conformity", "EvalNmbr", EvalNum)
    WarnCnt = RecordCount1Str1Lng("tblPROCESS_RESPONSES", "QRating", "Warning", "EvalNmbr", EvalNum)
    
    'Update the Parent form for the total number of NCIs found
    Me.Parent!TotalNumDefects = NCI_Cnt
    
    'Update the Parent form for the worst reported compliance
    If NCI_Cnt > 0 Then
        Me.Parent!Rating = "Non-Conformity"
    ElseIf WarnCnt > 0 Then
        Me.Parent!Rating = "Warning"
    Else
        Me.Parent!Rating = "Conformity"
    End If
    
    'Refresh the parent form to be consistent with the subform reported data
    If Me.Parent.Dirty Then Me.Parent.Dirty = False
    Me.Parent.Refresh
    
    'Reset the record displayed on the subform to the one that the user updated
    Me.QNmbr.SetFocus
    DoCmd.FindRecord QNum
    
'    Set rcdSet = Me.RecordsetClone
'    If rcdSet.Bookmarkable Then
'        rcdSet.FindFirst "QNmbr=" & QNum
'        If rcdSet.NoMatch Then
'            MsgBox "There were no records found for " & QNmbr, vbInformation
'        Else
'            varBookMark = rcdSet.Bookmark
'            Me.Bookmark = rcdSet.Bookmark
'        End If
'        Set rcdSet = Nothing
'    Else
'        MsgBox "This recordset is not bookmarkable", vbInformation
'    End If
    
End Sub
 
Last edited:

kcnewheart

New member
Local time
Today, 15:06
Joined
Jul 30, 2016
Messages
3
Well, I finally figured it out myself. I'm using the bookmark. But the problem was the refresh to the parent. Once that was removed, it worked fine...

Always the little things...
 

Users who are viewing this thread

Top Bottom