urguente ayuda con dos msflexgrid

sharly
19 de Junio del 2004
hola tengo mi problema es el siguiente, necesito llenar dos msflexgrid al mismo tiempo, pero con datos de dos tablas diferentes, relacionados ambos por el mismo campo que se ecuentra en las dos tablas de origen

rigel
19 de Junio del 2004
de que manera haces el llenado de los grids?

sharly
19 de Junio del 2004
mira este es el codigo que tengo:

Dim base As Database
Dim registros As Recordset
Dim num As String
Dim tabla3 As Recordset
Dim vtotal As Integer
'2
Dim registros2 As Recordset
Dim num2 As String
Dim tabla32 As Recordset
Dim vtotal2 As Integer
Dim enlace As MSFlexGrid
'
If Text1.Text <> Empty Then
Set base = OpenDatabase("C:Mis documentosoficiobd1.mdb")
Set registros = base.OpenRecordset("sgc")

num = Text1.Text
Set tabla3 = base.OpenRecordset("SELECT * FROM sgc WHERE FECINGRESO LIKE '*/" & num & "' ")

If tabla3.RecordCount > 0 Then
tabla3.MoveLast
vtotal = tabla3.RecordCount
tabla3.MoveFirst
MSFlexGrid1.Cols = 11
MSFlexGrid1.Rows = vtotal + 1
MSFlexGrid1.Col = 0
MSFlexGrid1.Row = 0
MSFlexGrid1.Text = "COD_EMPRESA"
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "ID_MEDIDOR"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "DIRECCION"
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = "CONSTANSTE"
MSFlexGrid1.Col = 4
MSFlexGrid1.Text = "COD_TECNOLOGIA"
MSFlexGrid1.Col = 5
MSFlexGrid1.Text = "COD_PROPIEDAD"
MSFlexGrid1.Col = 6
MSFlexGrid1.Text = "MARCA"
MSFlexGrid1.Col = 7
MSFlexGrid1.Text = "MODELO"
MSFlexGrid1.Col = 8
MSFlexGrid1.Text = "FECHA_FABRICACION"
MSFlexGrid1.Col = 9
MSFlexGrid1.Text = "NUMERO_SERIE"
MSFlexGrid1.Col = 10
MSFlexGrid1.Text = "FASES"
For i = 1 To vtotal

MSFlexGrid1.Col = 0
MSFlexGrid1.Row = i
MSFlexGrid1.Text = ("014")
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = tabla3("ESERIE")
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = tabla3("DIRECCION")
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = tabla3("CCONST")
MSFlexGrid1.Col = 4
MSFlexGrid1.Text = (" ")
MSFlexGrid1.Col = 5
MSFlexGrid1.Text = tabla3("E1")
MSFlexGrid1.Col = 6
MSFlexGrid1.Text = tabla3("EM")
MSFlexGrid1.Col = 7
MSFlexGrid1.Text = tabla3("EMODELO")
MSFlexGrid1.Col = 8
MSFlexGrid1.Text = tabla3("EAFAB")
MSFlexGrid1.Col = 9
MSFlexGrid1.Text = tabla3("ESERIE")
MSFlexGrid1.Col = 10
MSFlexGrid1.Text = tabla3("F")
MSFlexGrid3.Col = 0
MSFlexGrid3.Text = tabla3("ROL")

Set registros2 = base.OpenRecordset("dbo_vip_EMPBT0141")
Set tabla32 = base.OpenRecordset("SELECT * FROM dbo_vip_EMPBT0141 AS A " & _
"WHERE A.id_empalme ='" & MSFlexGrid3.Text & "' ")

If tabla32.RecordCount > 0 Then
tabla32.MoveLast
vtotal2 = tabla32.RecordCount
tabla32.MoveFirst
MSFlexGrid2.Cols = 12
MSFlexGrid2.Rows = vtotal2 + 1
MSFlexGrid2.Col = 0
MSFlexGrid2.Row = 0
MSFlexGrid2.Text = "COD_EMPRESA"
MSFlexGrid2.Col = 1
MSFlexGrid2.Text = "ID_MEDIDOR"
MSFlexGrid2.Col = 2
MSFlexGrid2.Text = "ID_CLIENTE"
MSFlexGrid2.Col = 3
MSFlexGrid2.Text = "PERIODO"
MSFlexGrid2.Col = 4
MSFlexGrid2.Text = "ID_TRANSFORMADOR"
MSFlexGrid2.Col = 5
MSFlexGrid2.Text = "ID_POSTE"
MSFlexGrid2.Col = 6
MSFlexGrid2.Text = "ID_CAMARA"
MSFlexGrid2.Col = 7
MSFlexGrid2.Text = "ID_TIPO_EMPALME"
MSFlexGrid2.Col = 8
MSFlexGrid2.Text = "COORD_X"
MSFlexGrid2.Col = 9
MSFlexGrid2.Text = "COORD_Y"
MSFlexGrid2.Col = 10
MSFlexGrid2.Text = "COD_COMUNA"
MSFlexGrid2.Col = 11
MSFlexGrid2.Text = "ESTADO_PTO_SUMINISTRO"

For y = 1 To vtotal2


MSFlexGrid2.Col = 0
MSFlexGrid2.Row = y
MSFlexGrid2.Text = ("014")
MSFlexGrid2.Col = 1
MSFlexGrid2.Text = tabla3("ESERIE")
MSFlexGrid2.Col = 2
MSFlexGrid2.Text = tabla32("id_empalme")
MSFlexGrid2.Col = 3
MSFlexGrid2.Text = Text1.Text
MSFlexGrid2.Col = 4
MSFlexGrid2.Text = tabla32("ID_TRANSFORMADOR")
MSFlexGrid2.Col = 5
MSFlexGrid2.Text = (" ")
MSFlexGrid2.Col = 6
MSFlexGrid2.Text = (" ")
MSFlexGrid2.Col = 7
MSFlexGrid2.Text = tabla32("tipo_tramo")
MSFlexGrid2.Col = 8
MSFlexGrid2.Text = (" ")
MSFlexGrid2.Col = 9
MSFlexGrid2.Text = (" ")
MSFlexGrid2.Col = 10
MSFlexGrid2.Text = (" 13201")
MSFlexGrid2.Col = 11
MSFlexGrid2.Text = (" ")
'agrega fila


tabla32.MoveNext

Next y

End If

fila = 2
For fila = 0 To i
If MSFlexGrid1.TextMatrix(fila, 5) = ("E") Then
MSFlexGrid1.Col = 5
MSFlexGrid1.Text = ("1")
fila = fila + 1
registros.MoveNext
End If
If MSFlexGrid1.TextMatrix(fila, 5) = ("C") Then
MSFlexGrid1.Col = 5
MSFlexGrid1.Text = ("2")
fila = fila + 1
registros.MoveNext
End If
Next fila
tabla3.MoveNext
Next i

Dim r As Integer
Dim k As Integer
Dim max_len As Single
Dim new_len As Single
Font.Name = MSFlexGrid1.Font.Name
Font.Size = MSFlexGrid1.Font.Size
For k = 0 To MSFlexGrid1.Cols - 1
max_len = 0
For r = 0 To MSFlexGrid1.Rows - 1
new_len = TextWidth(MSFlexGrid1.TextMatrix(r, k))
If max_len < new_len Then max_len = new_len
Next r
MSFlexGrid1.ColWidth(k) = max_len + 240
MSFlexGrid1.ColAlignment(k) = flexAlignLeftCenter
Next k

MSFlexGrid1.AllowUserResizing = flexResizeBoth
Command3.Enabled = True
Else
A = MsgBox("No Existen Registros", 48)

End If
End If
Text2.Text = i - 1
Text3.Text = y - 1
Text1.Enabled = False
Command2.Enabled = True




End Sub