none
Link DataBase RRS feed

  • Pregunta

  • Tengo un pequeño problema. Estoy creado una applicacion en access 2013. Estoy utilizando VBA code. Mi problema quizas sea simple pero no encuantro la respuesta. Cuando estoy trabajando con las tablas y los form juntos no tengo problemas pero a la hora que trabajo utilizando una base de datos externa mis combos box no muestran la informacion despues de realizas una busqueda. Este es el  codigo que estoy utilizando

                                        

    Private Sub cbSearch_Change()
        Dim rsR As DAO.Recordset
        Dim rsD As DAO.Recordset
        Dim rsC As DAO.Recordset
        Dim rsSH As DAO.Recordset
        Dim rsST As DAO.Recordset
        Dim rsDT As DAO.Recordset

        Dim strSQL As String

        Dim db As DAO.Database

        Set db = CurrentDb

        Set rsR = db.OpenRecordset("TblAssociate", dbOpenDynaset, adlockoptimistic)
        Set rsD = db.OpenRecordset("TblDepart", dbOpenDynaset, dbSeeChanges)
        Set rsC = db.OpenRecordset("TblComp", dbOpenDynaset, dbSeeChanges)
        Set rsSH = db.OpenRecordset("TblShift", dbOpenDynaset, dbSeeChanges)
        Set rsST = db.OpenRecordset("TblStatus", dbOpenDynaset, dbSeeChanges)
        Set rsDT = db.OpenRecordset("TblDuties", dbOpenDynaset, dbSeeChanges)

        If Me.cbSearch.Text <> "" And IsNull(Me.cbSearch.Column(0)) = False Then
            rsR.FindFirst "ID_Assoc =" & Me.cbSearch.Column(0)
            If rsR.RecordCount > 0 Then
                Me.txtidassoc = Me.cbSearch.Column(0)
                Me.txtFullName = rsR![AssocFullName]
                Me.txtStartDate = rsR![AssocStartDate]
                Me.txtEndDate = rsR![AssocEndDate]
                Me.txtComments = rsR![comments]
                Me.cbDuties = rsR![duties]

                rsD.FindFirst "ID_Depart =" & rsR![DepartName]
                Me.cbDepartment = rsD![DepartName]
                Me.txtiddepa = rsD![ID_Depart]
      

                rsSH.FindFirst "ID_Shift =" & rsR![ShiftName]
                Me.cbShift = rsSH![ShiftName]
                Me.txtidshift = rsSH![ID_Shift]

                rsC.FindFirst "ID_Company =" & rsR![CompName]
                Me.cbCompany = rsC![CompName]
                Me.txtidcompa = rsC![ID_Company]

                rsST.FindFirst "ID_Status =" & rsR![StatusName]
                Me.cbStatus = rsST![StatusName]
                Me.txtidsta = rsST![ID_Status]

                If IsNull(rsR![duties]) = False Then
                    rsDT.FindFirst "ID_Duties =" & rsR![duties]
                    Me.cbDuties = rsDT![DutiesName]
                    Me.txtIDduties = rsDT![ID_Duties]
                End If

                'SQL to find what training associate have.
                strSQL = "SELECT [QListEmplWithTraining Query].ID, [QListEmplWithTraining Query].TblAssociate_AssocFullName, [QListEmplWithTraining Query].StandarWork AS [Standar Work], [QListEmplWithTraining Query].DepartName AS Department, [QListEmplWithTraining Query].TrainingDate AS [Training Date], [QListEmplWithTraining Query].TrainerName AS Trainer " _
                        & " FROM [QListEmplWithTraining Query]" _
                        & " WHERE ID =" & Me.txtidassoc

                Me.LstView.RowSource = strSQL
                Me.LstView.Requery

                If rsR![JobReiting] <> "" And rsR![JobReiting] <> 0 Then
                    Me.Frame78.Value = rsR![JobReiting]
                End If
                Me.TxtFORM = "E"
            End If
        ElseIf IsNull(Me.cbSearch.Column(0)) = True Or Trim(Me.cbSearch.Text) = "" Then
            Call CleanForm
        End If

        rsR.Close
        rsD.Close
        rsC.Close
        rsSH.Close
        rsST.Close

        Set db = Nothing
        Set rsR = Nothing
        Set rsD = Nothing
        Set rsC = Nothing
        Set rsSH = Nothing
        Set rsST = Nothing

    End Sub

    viernes, 15 de mayo de 2015 1:44