no current record found for new version

pbuethe

Returning User
Local time
Today, 18:44
Joined
Apr 9, 2002
Messages
210
I have a frmFindRecord where I select from cascading combo boxes:
cboFacility, cboReviewType, cboSample, cboCaseNo.

Then I click a button which has the following code:
Code:
Private Sub cmdFindRecord_Click()
On Error GoTo Err_cmdFindRecord_Click


    Dim strWhere As String
    Dim strFormId As String
    Dim strCaseId As String
    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim qry As New QueryDef
    
    Dim lUserId As Long
    
    Dim strPDFormId As String
    Dim strARVEFormId As String
    Dim strARVDFormId As String
    Dim strMTBFormId As String
    Dim strGYNFormId As String
    Dim strSUOFormId As String
    Dim strHEPCFormId As String
    Dim strMHAFormId As String
    
  
'get the selected CaseID
    'strCaseId = Me.sfrmErrorLog.Controls.Item("Case ID").Value
    strCaseId = Form_frmFindRecord.cboCaseNo.Value
    lUserId = Form_frmFindRecord.intUserID.Value

    'set the screen values
    SetScreenValues lUserId, strCaseId, True

    'set tblAppEnv with CaseID and FormIDs
    Set qry = CurrentDb.QueryDefs("qryGetScreenValues")
    qry.Parameters("pUserId") = lUserId

    strCaseId = qry.OpenRecordset.Fields("CaseId").Value
    strPDFormId = qry.OpenRecordset.Fields("PDFormId").Value
    strARVEFormId = qry.OpenRecordset.Fields("ARVEFormId").Value
    strARVDFormId = qry.OpenRecordset.Fields("ARVDFormId").Value
    strMTBFormId = qry.OpenRecordset.Fields("MTBFormId").Value
    strGYNFormId = qry.OpenRecordset.Fields("GYNFormId").Value
    strSUOFormId = qry.OpenRecordset.Fields("SUOFormId").Value
    strHEPCFormId = qry.OpenRecordset.Fields("HEPCFormId").Value
    strMHAFormId = qry.OpenRecordset.Fields("MHAFormId").Value

    qry.Close
      
    
    strWhere = "CaseID = '" & strCaseId & "'"

    ' AND Form_Id = " & dFormID
    'Open all the forms and set focus to selected form
    DoCmd.OpenForm "frm" & strPDFormId, acNormal, , strWhere, , , Me.intUserID

Exit_cmdFindRecord_Click:
    Exit Sub

Err_cmdFindRecord_Click:
    MsgBox Err.Description, vbCritical
    Resume Exit_cmdFindRecord_Click
    
End Sub

SetScreenValues is in a module and is as follows:
Code:
Public Sub SetScreenValues(lUserId As Long, strCaseId As String, blnSet As Boolean)

    Dim qry As New QueryDef
    Dim strPDFormId As String
    Dim strARVEFormId As String
    Dim strARVDFormId As String
    Dim strMTBFormId As String
    Dim strGYNFormId As String
    Dim strSUOFormId As String
    Dim strHEPCFormId As String
    Dim strMHAFormId As String
  MsgBox "lUserID = " & lUserId & "; strCaseID = " & strCaseId
    If blnSet = True Then
    MsgBox "SetScreenValues, blnSet = True"
        'set tblAppEnv with CaseID and FormIDs
        Set qry = CurrentDb.QueryDefs("qryGetFormId")
        qry.Parameters("pCaseID") = strCaseId

        strPDFormId = qry.OpenRecordset.Fields("PDFormId").Value
    MsgBox "strPDFormID = " & strPDFormId
        strARVEFormId = qry.OpenRecordset.Fields("ARVFormId").Value & "E"
        strARVDFormId = qry.OpenRecordset.Fields("ARVFormId").Value & "D"
        strMTBFormId = qry.OpenRecordset.Fields("MTBFormId").Value
        strGYNFormId = qry.OpenRecordset.Fields("GYNFormId").Value
        strSUOFormId = qry.OpenRecordset.Fields("SUOFormId").Value
        strHEPCFormId = qry.OpenRecordset.Fields("HEPFormId").Value
        strMHAFormId = qry.OpenRecordset.Fields("MHAFormId").Value

        qry.Close
    Else
    MsgBox "blnSet = False"
        strPDFormId = Empty
        strARVEFormId = Empty
        strARVDFormId = Empty
        strMTBFormId = Empty
        strGYNFormId = Empty
        strSUOFormId = Empty
        strHEPCFormId = Empty
        strMHAFormId = Empty
    End If
    
    ExecuteQuery "qupdScreenValues", lUserId, strCaseId, strPDFormId, strARVEFormId, strARVDFormId, strMTBFormId, strGYNFormId, strSUOFormId, strHEPCFormId, strMHAFormId
MsgBox "set screen values"
End Sub

Explanation:
Each main table has a field FormID to identify the form to be used with each record. This is because our forms (paper forms which are scanned) go through multiple versions. When a case number is selected, this code should write the FormIDs for each table to a table called tblAppEnv. Then it should open the header form using the version corresponding to the active record. It was working fine when I selected records using the original version of the form, but when I selected any record which uses the second version of the header form (there are only 2 versions right now but there may be more in the future), it gave me the message "no current record."

I put in the msgboxes to see how far it was getting. It gets up to the "SetScreenValues, blnSet = True". Then it seems to forget the value of strCaseID, and displays the "no current record". And it does not write to tblAppEnv.

I hope I have explained this enough. Let me know if you want more details. Thanks for your assistance.
 

Users who are viewing this thread

Back
Top Bottom