border

Miembros:
Mensajes:
Temas:
Online:

Ultimo Miembro:

 
 


Retroceder   VB-MUNDO - Programacion Visual > Programacion - Lenguajes > Visual Basic 6.00
Registrarse FAQ Miembros Calendario Buscar Temas de Hoy Marcar Foros Como Leídos

Respuesta
 
LinkBack Herramientas Desplegado
  #1 (permalink)  
Antiguo 31-03-2005, 20:54:51
Buena Participación en el Foro
 
Registrado: mar 2005
Ubicación: Buenos Aires
Posts: 40
Poplanet Valoración +2
Contactar con Poplanet a través de ICQ Contactar con Poplanet a través de MSN
Predeterminado Como agregar datos a un COMBOBOX en tiempo de ejecucion

Hola mi pregunta es la siguiente yo tengo un proyecto realizado en visual y estas conectado a una base de datos... lo que necesito es lo siguiente como puedo cargar un combo en tiempo de ejecucion....


GRACIAS :smt009
__________________
Hola mi nombre es Martin y me interesa mucho la programacion, en especial Visual Basic 6.0
Responder Con Cita
  #2 (permalink)  
Antiguo 31-03-2005, 21:19:26
Avatar de Claudia
Gran Participación en el Foro
 
Registrado: ene 2005
Ubicación: Lima
Posts: 489
Claudia Valoración +2
Contactar con Claudia a través de MSN Contactar con Claudia a través de Yahoo
Predeterminado

Hola Martin , espero que esto te sirva :smt002

Código:
'En el Load 

'Origen
Set rsOrigen = New ADODB.Recordset
rsOrigen.CursorLocation = adUseClient
SQL = "SELECT * FROM ORIGEN where tip_orig =" & Chr(39) & 1 & Chr(39) & " AND cod_cia =" & Chr(39) & codcia & Chr(39) & " order by nom_orig"
rsOrigen.Open SQL, CN, adOpenStatic, adLockReadOnly
Do While Not rsOrigen.EOF
    Combo2.AddItem rsOrigen!nom_orig: rsOrigen.MoveNext
Loop

'En el Click
Private Sub Combo2_Click()
Set rsOrigen = New ADODB.Recordset
rsOrigen.CursorLocation = adUseClient
SQL = "SELECT cod_orig FROM origen where tip_orig =" & Chr(39) & 1 & Chr(39) & " AND cod_cia =" & Chr(39) & codcia & Chr(39) & " and nom_orig = " & Chr(39) & Combo2.Text & Chr(39)
rsOrigen.Open SQL, CN, adOpenStatic, adLockReadOnly
If Combo2.ListIndex <> -1 Then Label5.Caption = rsOrigen!cod_orig
End Sub
__________________
Claudia Rossmery Chumpitaz Torres
Responder Con Cita
  #3 (permalink)  
Antiguo 31-03-2005, 21:35:18
Buena Participación en el Foro
 
Registrado: mar 2005
Ubicación: Buenos Aires
Posts: 40
Poplanet Valoración +2
Contactar con Poplanet a través de ICQ Contactar con Poplanet a través de MSN
Predeterminado Cargar datos en un combo

A continuacion paso el codigo completo y como me conecto a la base de datos a ver si esto puede ayudar





Option Explicit
Dim grid1 As Boolean, grid2 As Boolean
Dim rsDeu As Recordset
Dim Condi As String

Private Sub Command3_Click()

End Sub

Private Sub Command4_Click()

Unload Me
End

End Sub

Private Sub Command5_Click()

Combo1.Text = "TODAS"
Combo4.Text = "TODAS"
Combo2.Text = "TODOS"
Combo5.Text = "TODAS"
cboLocalidad.Text = "TODAS"

'Combo1.Text = ""
'Combo2.Text = ""
'Combo3.Text = ""
'Combo4.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
'txtbusqueda.Text = ""

MSFlexGrid2.Visible = False

MSFlexGrid1.Rows = 0

End Sub

Private Sub Command6_Click()
Dim Sq15 As String
Dim diez15 As Integer

Sq15 = " Select * From Tbldeudores where (((tbldeudores.Baja)Like '" + Trim(Me.Combo5.Text) + "*'))"
Set rsDeu = Vada.OpenRecordset(Sq15)
If (Not rsDeu.BOF) And (Not rsDeu.EOF) Then

With Me.MSFlexGrid1

.Rows = 1
.Cols = 8
.Row = 0
.Col = 0
.Text = "Nro."
.CellAlignment = 4
.ColWidth(.Col) = 400
.Col = 1

.Text = "Cuenta"
.CellAlignment = 4
.ColWidth(.Col) = 850
.Col = 2

.Text = "Apellido y Nombre"
.CellAlignment = 4
.ColWidth(.Col) = 2444
.Col = 3

.Text = "Telefono"
.CellAlignment = 5
.ColWidth(.Col) = 1750
.Col = 4


.Text = "Documento"
.CellAlignment = 4
.ColWidth(.Col) = 1132
.Col = 5


.Text = "Estado de Cuenta"
.CellAlignment = 4
.ColWidth(.Col) = 2000
.Col = 6

.Text = "Localidad"
.CellAlignment = 4
.ColWidth(.Col) = 1500


' .Text = "Baja"
'.CellAlignment = 4
'.ColWidth(.Col) = 950


rsDeu.MoveLast
For diez15 = 1 To rsDeu.RecordCount
If diez15 = 1 Then
rsDeu.MoveFirst
Else
rsDeu.MoveNext
End If

.Rows = .Rows + 1
.Row = .Rows - 1
.Col = 0
.Text = diez15
.Col = 1
.Text = IIf(IsNull(rsDeu![cuenta]), " ", rsDeu![cuenta])
.Col = 2
.Text = IIf(IsNull(rsDeu![Apellido]), " ", rsDeu![Apellido])
.Col = 3
.Text = IIf(IsNull(rsDeu![Telefono]), " ", rsDeu![Telefono])
.Col = 4
.Text = IIf(IsNull(rsDeu![Documento]), " ", rsDeu![Documento])
.Col = 5
.Text = IIf(IsNull(rsDeu![estado]), " ", rsDeu![estado])
.Col = 6
.Text = IIf(IsNull(rsDeu![Domicilio]), " ", rsDeu![Domicilio])
' .Col = 7
'.Text = IIf(IsNull(rsDeu![Baja]), " ", rsDeu![Baja])







Next
End With

Else

MsgBox "Base de datos vacía.", vbApplicationModal + vbInformation, "Mensaje"

End If
rsDeu.Close
Set rsDeu = Nothing



End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
Me.MSFlexGrid2.Visible = False
Me.MSFlexGrid1.Enabled = True
End If
End Sub
Sub Form2_Grid2()
On Error GoTo Form2_Grid2_Error
'************************************************* ************************
On Error Resume Next
Dim s As String
Dim Formu As String
Dim rsG As Recordset
s = MsgBox("Desea Modificar los datos.........", vbYesNo, "Mensaje")
If s = 6 Then
Dim emp As String
Set rsG = Vada.OpenRecordset("select * from [tbldeudores] where cuenta = '" & Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1) & "'")
emp = Mid(Me.Combo1.Text, 8, 11)
If emp = "Gas Ban" Then
If (Not rsG.BOF) And (Not rsG.EOF) Then
telefonica.Text2.Text = rsG!cuenta
telefonica.Text5.Text = rsG!Apellido
telefonica.Text27.Text = rsG!estado
telefonica.Text1.Text = rsG!Documento
telefonica.Text3.Text = rsG!Telefono
telefonica.Text7.Text = rsG!calle
telefonica.Text8.Text = rsG!barrio
telefonica.Text4.Text = rsG!Domicilio
telefonica.Text9.Text = rsG!provincia
telefonica.Text10.Text = rsG!cod_post
telefonica.Text12.Text = rsG!importe
telefonica.Text26.Text = rsG!Telefono1
telefonica.Text32.Text = rsG!Domicilio
telefonica.Text22.Text = rsG!cod_post
telefonica.Text25.Text = Date
telefonica.Text24.Text = Time
'telefonica.Text6.Text = rsG!piso
'telefonica.Text11.Text = rsG!dpto

Dim rsGes As Recordset
Dim rsEqui As Recordset
Dim rsDue As Recordset
Dim rsult As Recordset
Dim rsac As Recordset
Dim rsult1 As Recordset
Dim rsequi1 As Recordset
Dim domsu As Recordset

Set rsGes = Vada.OpenRecordset("select * from gestion where cuenta = '" & rsG!cuenta & "'")
Set rsEqui = Vada.OpenRecordset("select * from equipo where cuenta = '" & rsG!cuenta & "' order by añobaja")
Set rsult = Vada.OpenRecordset("select * from ultimos where cuenta = '" & rsG!cuenta & "'")

Set rsac = Vada.OpenRecordset("select* from actualizaciones where cuenta='" & rsG!cuenta & "'")

If (Not rsult.BOF) And (Not rsult.EOF) Then
telefonica.Text28.Text = IIf(IsNull(rsult![telefonos1]), "", rsult![telefonos1])
telefonica.Text32.Text = IIf(IsNull(rsult![Domicilio]), "", rsult![Domicilio])
telefonica.Text22.Text = IIf(IsNull(rsult![Cod_postal]), "", rsult![Cod_postal])


End If


Set domsu = Vada.OpenRecordset("select* from domsu where cuenta='" & rsG!cuenta & "'")

If (Not domsu.BOF) And (Not domsu.EOF) Then

telefonica.Text6.Text = IIf(IsNull(domsu![domsu]), "", domsu![domsu])

End If


Set rsDeu = Vada.OpenRecordset("select * from deuda where cuenta = '" & rsG!cuenta & "' and id_emp = '" & rsG!id & "'")
If (Not rsDeu.BOF) And (Not rsDeu.EOF) Then
rsDeu.MoveLast
rsDeu.MoveFirst
telefonica.Text12.Text = IIf(IsNull(rsDeu![monto]), " ", rsDeu![monto])
telefonica.Text15.Text = IIf(IsNull(rsDeu![fecha]), " ", rsDeu![fecha])
rsDeu.MoveLast
telefonica.Text18.Text = IIf(IsNull(rsDeu![monto]), " ", rsDeu![monto])
telefonica.Text19.Text = IIf(IsNull(rsDeu![hon]), " ", rsDeu![hon])
telefonica.Text20.Text = IIf(IsNull(rsDeu![total]), " ", rsDeu![total])
telefonica.Text21.Text = IIf(IsNull(rsDeu![fecha]), " ", rsDeu![fecha])
End If


If (Not rsac.BOF) And (Not rsac.EOF) Then
With telefonica.MSFlexGrid3
.Rows = 1
.Cols = 2
.Row = 0
.Col = 0
.Text = "Nro."
.CellAlignment = 4
.ColWidth(.Col) = 700
.Col = 1

.Text = "Importe"
.CellAlignment = 4
.ColWidth(.Col) = 1000


' .Text = "V.Abono"
' .CellAlignment = 4
' .ColWidth(.Col) = 1000
' .Col = 3

' .Text = "Imp.Original"
' .CellAlignment = 4
' .ColWidth(.Col) = 1500
' .Col = 4


'.Text = "S.Deuda"
'.CellAlignment = 4
'.ColWidth(.Col) = 1070
'.Col = 5

'.Text = "Saldo D."
'.CellAlignment = 4
'.ColWidth(.Col) = 1070

rsac.MoveLast
'rsac.MoveFirst
Dim Asi1 As Integer

For Asi1 = 1 To rsac.RecordCount
If Asi1 = 1 Then
rsac.MoveFirst
Else
rsac.MoveNext
End If


.Rows = .Rows + 1
.Row = .Rows - 1
.Col = 0
.Text = Asi1
.Col = 1
.Text = IIf(IsNull(rsac![importe]), " ", rsac![importe])
'.Col = 2
'.Text = IIf(IsNull(rsEqui![añobaja]), " ", rsEqui![añobaja])
'.Col = 3
'.Text = IIf(IsNull(rsEqui![equipo]), " ", rsEqui![equipo])
'.Col = 4
'.Text = IIf(IsNull(rsEqui![Nroserie1]), " ", rsEqui![Nroserie1])
'.Col = 5
'.Text = IIf(IsNull(rsEqui![nroserie2]), " ", rsEqui![nroserie2])
'.Text = Format(rsDeu![Saldo], "0.00")
If Asi1 = rsac.RecordCount Then Exit For
rsac.MoveNext
Next
End With
'Else
' MsgBox "No Existen Gestiones en esta cuenta.", vbApplicationModal + vbInformation, "Mensaje"
End If

'Aca arriba estoy escribiendo una actualizacion de pagos





























If (Not rsEqui.BOF) And (Not rsEqui.EOF) Then
With telefonica.MSFlexGrid2

.Rows = 1
.Cols = 6
.Row = 0
.Col = 0
.Text = "Nro."
.CellAlignment = 4
.ColWidth(.Col) = 400
.Col = 1

.Text = "Tipo Comp."
.CellAlignment = 4
.ColWidth(.Col) = 1000
.Col = 2

.Text = "NºComp."
.CellAlignment = 4
.ColWidth(.Col) = 1000
.Col = 3

.Text = "F.Emision"
.CellAlignment = 4
.ColWidth(.Col) = 1500
.Col = 4


.Text = "Importe"
.CellAlignment = 4
.ColWidth(.Col) = 1070
.Col = 5

.Text = " Estado."
.CellAlignment = 4
.ColWidth(.Col) = 1070

rsEqui.MoveLast
Dim Asi As Integer
For Asi = 1 To rsEqui.RecordCount
If Asi = 1 Then
rsEqui.MoveFirst
Else
rsEqui.MoveNext
End If

.Rows = .Rows + 1
.Row = .Rows - 1
.Col = 0
.Text = Asi
.Col = 1
.Text = IIf(IsNull(rsEqui![nroabonado]), " ", rsEqui![nroabonado])
.Col = 2
.Text = IIf(IsNull(rsEqui![añobaja]), " ", rsEqui![añobaja])
.Col = 3
.Text = IIf(IsNull(rsEqui![equipo]), " ", rsEqui![equipo])
.Col = 4
.Text = IIf(IsNull(rsEqui![Nroserie1]), " ", rsEqui![Nroserie1])
.Col = 5
.Text = IIf(IsNull(rsEqui![nroserie2]), " ", rsEqui![nroserie2])
'.Text = Format(rsDeu![Saldo], "0.00")
If Asi = rsEqui.RecordCount Then Exit For
Next
End With
'Else
' MsgBox "No Existen Gestiones en esta cuenta.", vbApplicationModal + vbInformation, "Mensaje"
End If







If (Not rsGes.BOF) And (Not rsGes.EOF) Then
With telefonica.MSFlexGrid1

.Rows = 1
.Cols = 6
.Row = 0
.Col = 0
.Text = "Nro."
.CellAlignment = 4
.ColWidth(.Col) = 400
.Col = 1

.Text = "Cuenta"
.CellAlignment = 4
.ColWidth(.Col) = 950
.Col = 2

.Text = "Fecha"
.CellAlignment = 4
.ColWidth(.Col) = 1000
.Col = 3

.Text = "Hora"
.CellAlignment = 4
.ColWidth(.Col) = 1000
.Col = 4


.Text = "Estado"
.CellAlignment = 4
.ColWidth(.Col) = 2000

.Col = 5
.Text = ""
.CellAlignment = 4
.ColWidth(.Col) = 0

rsGes.MoveLast
For Asi = 1 To rsGes.RecordCount
If Asi = 1 Then
rsGes.MoveFirst
Else
rsGes.MoveNext
End If

.Rows = .Rows + 1
.Row = .Rows - 1
.Col = 0
.Text = Asi
.Col = 1
.Text = IIf(IsNull(rsGes![cuenta]), " ", rsGes![cuenta])
.Col = 2
.Text = IIf(IsNull(rsGes![fecha]), " ", rsGes![fecha])
.Col = 3
.Text = IIf(IsNull(rsGes![hora]), " ", rsGes![hora])
.Col = 4
.Text = IIf(IsNull(rsGes![estado]), " ", rsGes![estado])
telefonica.Text27.Text = rsGes!estado
.Col = 5
.Text = IIf(IsNull(rsGes![observaciones]), " ", rsGes![observaciones])
'.Text = Format(rsDeu![Saldo], "0.00")
If Asi = rsGes.RecordCount Then Exit For
Next
End With
End If

rsG.Close
rsGes.Close
rsEqui.Close
rsDeu.Clone
Set rsEqui = Nothing
Set rsDeu = Nothing
Set rsGes = Nothing
Set rsG = Nothing
Form1.Visible = False
telefonica.Show
End If
Else

If (Not rsG.BOF) And (Not rsG.EOF) Then
Form2.Text2.Text = rsG!cuenta
Form2.Text5.Text = rsG!Apellido
' Form2.Text6.Text = rsG!Nombre
Form2.Text1.Text = rsG!Documento
Form2.Text3.Text = rsG!Telefono
Form2.Text7.Text = rsG!calle
Form2.Text8.Text = rsG!barrio
Form2.Text4.Text = rsG!Domicilio
Form2.Text9.Text = rsG!provincia
Form2.Text10.Text = rsG!cod_post
'Form2.Text11.Text = rsG!nac
Form2.Text28.Text = rsG!Telefono
Form2.Text32.Text = rsG!Domicilio
Form2.Text22.Text = rsG!cod_post
Form2.Text25.Text = Date
Form2.Text24.Text = Time
Form2.Text12.Text = rsG!importe


Set rsDeu = Vada.OpenRecordset("select * from deuda where cuenta = '" & rsG!cuenta & "' and id_emp = '" & rsG!id & "'")
If (Not rsDeu.BOF) And (Not rsDeu.EOF) Then
rsDeu.MoveLast
rsDeu.MoveFirst
telefonica.Text15.Text = IIf(IsNull(rsDeu![monto]), " ", rsEqui![monto])
telefonica.Text12.Text = IIf(IsNull(rsEqui![fecha]), " ", rsEqui![fecha])
rsDeu.MoveLast
telefonica.Text18.Text = IIf(IsNull(rsDeu![monto]), " ", rsEqui![monto])
telefonica.Text19.Text = IIf(IsNull(rsEqui![hon]), " ", rsEqui![hon])
telefonica.Text20.Text = IIf(IsNull(rsDeu![total]), " ", rsEqui![total])
telefonica.Text21.Text = IIf(IsNull(rsEqui![fecha]), " ", rsEqui![fecha])
End If

Set rsequi1 = Vada.OpenRecordset("select * from equipo2 where cuenta = '" & rsG!cuenta & "'")
If (Not rsequi1.BOF) And (Not rsequi1.EOF) Then
With Form2.MSFlexGrid2
.Rows = 1
.Cols = 5
.Row = 0
.Col = 0
.Text = "Nro."
.CellAlignment = 4
.ColWidth(.Col) = 400
.Col = 1

.Text = "Fecha Venc."
.CellAlignment = 4
.ColWidth(.Col) = 1000
.Col = 2

.Text = "V.Abonado"
.CellAlignment = 4
.ColWidth(.Col) = 1000
.Col = 3

.Text = "N°Factura"
.CellAlignment = 4
.ColWidth(.Col) = 1500
.Col = 4


.Text = "S.Deuda"
.CellAlignment = 4
.ColWidth(.Col) = 1070
'.Col = 5

'.Text = " Estado."
'.CellAlignment = 4
'.ColWidth(.Col) = 1070

rsequi1.MoveLast
Dim Asi2 As Integer
For Asi2 = 1 To rsequi1.RecordCount
If Asi2 = 1 Then
rsequi1.MoveFirst
Else
rsequi1.MoveNext
End If

.Rows = .Rows + 1
.Row = .Rows - 1
.Col = 0
.Text = Asi2
.Col = 1
.Text = IIf(IsNull(rsequi1![Fvenc]), " ", rsequi1![Fvenc])
.Col = 2
.Text = IIf(IsNull(rsequi1![VAbono]), " ", rsequi1![VAbono])
.Col = 3
.Text = IIf(IsNull(rsequi1![Nfac]), " ", rsequi1![Nfac])
.Col = 4
.Text = IIf(IsNull(rsequi1![sdeuda]), " ", rsequi1![sdeuda])
'.Col = 5
'.Text = IIf(IsNull(rsequi1![nroserie2]), " ", rsequi1![nroserie2])
'Text = Format(rsDeu![Saldo], "0.00")
If Asi2 = rsequi1.RecordCount Then Exit For
Next
End With
'Else
' MsgBox "No Existen Gestiones en esta cuenta.", vbApplicationModal + vbInformation, "Mensaje"
End If
















Set rsult1 = Vada.OpenRecordset("select * from ultimos where cuenta = '" & rsG!cuenta & "'")

If (Not rsult1.BOF) And (Not rsult1.EOF) Then
Form2.Text28.Text = IIf(IsNull(rsult1![telefonos1]), "", rsult1![telefonos1])
Form2.Text32.Text = IIf(IsNull(rsult1![Domicilio]), "", rsult1![Domicilio])
Form2.Text22.Text = IIf(IsNull(rsult1![Cod_postal]), "", rsult1![Cod_postal])














End If
Set rsGes = Vada.OpenRecordset("select * from gestion where cuenta = '" & rsG!cuenta & "'")
If (Not rsGes.BOF) And (Not rsGes.EOF) Then
With Form2.MSFlexGrid1

.Rows = 1
.Cols = 6
.Row = 0
.Col = 0
.Text = "Nro."
.CellAlignment = 4
.ColWidth(.Col) = 400
.Col = 1

.Text = "Cuenta"
.CellAlignment = 4
.ColWidth(.Col) = 950
.Col = 2

.Text = "Fecha"
.CellAlignment = 4
.ColWidth(.Col) = 1000
.Col = 3

.Text = "Hora"
.CellAlignment = 4
.ColWidth(.Col) = 1000
.Col = 4


.Text = "Estado"
.CellAlignment = 4
.ColWidth(.Col) = 2000

.Col = 5
.Text = ""
.CellAlignment = 4
.ColWidth(.Col) = 0

rsGes.MoveLast
For Asi = 1 To rsGes.RecordCount
If Asi = 1 Then
rsGes.MoveFirst
Else
rsGes.MoveNext
End If

.Rows = .Rows + 1
.Row = .Rows - 1
.Col = 0
.Text = Asi
.Col = 1
.Text = IIf(IsNull(rsGes![cuenta]), " ", rsGes![cuenta])
.Col = 2
.Text = IIf(IsNull(rsGes![fecha]), " ", rsGes![fecha])
.Col = 3
.Text = IIf(IsNull(rsGes![hora]), " ", rsGes![hora])
.Col = 4
.Text = IIf(IsNull(rsGes![estado]), " ", rsGes![estado])
Form2.Text27.Text = rsGes!estado
.Col = 5
.Text = IIf(IsNull(rsGes![observaciones]), " ", rsGes![observaciones])
'.Text = Format(rsDeu![Saldo], "0.00")
If Asi = rsGes.RecordCount Then Exit For
Next

End With

' Else
' MsgBox "No Existen Gestiones en esta cuenta.", vbApplicationModal + vbInformation, "Mensaje"
End If
rsG.Close
rsGes.Close
rsEqui.Close
rsDeu.Clone
Set rsEqui = Nothing
Set rsDeu = Nothing
Set rsGes = Nothing
Set rsG = Nothing
Form1.Visible = False
Form2.Show
End If

End If

Else
'Me.Text1.Text = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1)
'Me.Text4.Text = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 2)
' Me.txtbusqueda.Text = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 3)
'Text2.Text = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 4)
'Text3.Text = rsG!telefono
'Me.Combo2.Text = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 5)
Me.MSFlexGrid2.Visible = False
Set rsG = Vada.OpenRecordset("select * from gestion where cuenta = '" & Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1) & "'")
If (Not rsG.BOF) And (Not rsG.EOF) Then

With Me.MSFlexGrid2
'Me.MSFlexGrid2.Visible = True
.Rows = 1
.Cols = 5
.Row = 0
.Col = 0
.Text = "Nro."
.CellAlignment = 4
.ColWidth(.Col) = 400
.Col = 1

.Text = "Cuenta"
.CellAlignment = 4
.ColWidth(.Col) = 950
.Col = 2

.Text = "Fecha"
.CellAlignment = 4
.ColWidth(.Col) = 1000
.Col = 3

.Text = "Hora"
.CellAlignment = 4
.ColWidth(.Col) = 1000
.Col = 4


.Text = "Estado"
.CellAlignment = 4
.ColWidth(.Col) = 2000



rsG.MoveLast
For Asi = 1 To rsG.RecordCount
If Asi = 1 Then
rsG.MoveFirst
Else
rsG.MoveNext
End If

.Rows = .Rows + 1
.Row = .Rows - 1
.Col = 0
.Text = Asi
.Col = 1
.Text = IIf(IsNull(rsG![cuenta]), " ", rsG![cuenta])
.Col = 2
.Text = IIf(IsNull(rsG![fecha]), " ", rsG![fecha])
.Col = 3
.Text = IIf(IsNull(rsG![hora]), " ", rsG![hora])
.Col = 4
.Text = IIf(IsNull(rsG![estado]), " ", rsG![estado])

'.Text = Format(rsDeu![Saldo], "0.00")
If Asi = rsG.RecordCount Then Exit For
Next
End With

Else

MsgBox "Base de datos vacía.", vbApplicationModal + vbInformation, "Mensaje"

End If

rsG.Close
Set rsG = Nothing

End If
'************************************************* ************************
On Error GoTo 0
Exit Sub

Form2_Grid2_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") en el procedimiento Form2_Grid2 del Formulario Form1"
End Sub
Sub Cargargrid()
Dim Sq As String
Dim Diez As Integer
Dim sSql As String

'Sq = "SELECT * From TBLDEUDORES ORDER BY [tbldeudores].[Baja]" 'WHERE (((tbldeudores.Baja)='" + Trim(Me.combo5.Text) + "'))"
' If Condi = "Text" And Me.Combo1.Text <> "Todas" Then
' Sq = ("select * from tbldeudores where " & Campo & " Like '" + Trim(cValor) + "*' and id= '" & Mid(Me.Combo1.Text, 1, 5) & "'")
' ElseIf Condi = "Combo" And Me.Combo1.Text <> "Todas" And Combo4.Text <> "" Then 'And Text1.Text <> "" Then
' Sq = "SELECT * From tbldeudores WHERE " & Campo & " Like '" + Trim(cValor) + "*' and id= '" & Mid(Me.Combo1.Text, 1, 5) & "' and nro_cart = '" & Trim(Me.Combo4.Text) & "' and cuenta='" & Trim(Me.Text1.Text) & "'"
' ElseIf Condi = "Combo" And Me.Combo1.Text <> "Todas" Then
' Sq = "SELECT * From tbldeudores WHERE " & Campo & " Like '" + Trim(cValor) + "*' and id= '" & Mid(Me.Combo1.Text, 1, 5) & "'"
' End If

'Empresa
If UCase(Combo1.Text) <> "TODAS" And Trim(Combo1.Text) <> "" Then
Sq = AgregarTexto(Sq, "id = '" & Format(Combo1.ItemData(Combo1.ListIndex), "00000") & "'")
End If

'Localidad
If UCase(cboLocalidad.Text) <> "TODAS" And Trim(cboLocalidad.Text) <> "" Then
Sq = AgregarTexto(Sq, "domicilio = '" & Trim(cboLocalidad.Text) & "'")
End If

'Nro.
If UCase(Combo4.Text) <> "TODAS" And Trim(Combo4.Text) <> "" Then
Sq = AgregarTexto(Sq, "nro_cart = '" & Trim(Combo4.Text) & "'")
End If

'Estado
If UCase(Combo2.Text) <> "TODOS" And Trim(Combo2.Text) <> "" Then
Sq = AgregarTexto(Sq, "Estado = '" & Trim(Combo2.Text) & "'")
End If

'Documento
If UCase(Text2.Text) <> "" Then
Sq = AgregarTexto(Sq, "Documento LIKE '*" & Trim(Text2.Text) & "*'")
End If

'Apellido
If Trim(Text4.Text) <> "" Then
Sq = AgregarTexto(Sq, "Apellido LIKE '*" & Trim(Text4.Text) & "*'")
End If

'Telefono
If Trim(Text3.Text) <> "" Then
Sq = AgregarTexto(Sq, "Telefono LIKE '*" & Trim(Text3.Text) & "*'")
End If

'Nro. Cuenta
If Trim(Text1.Text) <> "" Then
Sq = AgregarTexto(Sq, "Cuenta LIKE '*" & Trim(Text1.Text) & "*'")
End If

'Baja
If UCase(Combo5.Text) <> "TODAS" And Trim(Combo5.Text) <> "" Then
Sq = AgregarTexto(Sq, "Baja = '" & Combo5.Text & "'")
End If

MSFlexGrid2.Visible = False


'Armo el Query
If Trim(Sq) = "" Then
sSql = "SELECT * FROM TBLDEUDORES ORDER BY Baja"
Else
sSql = "SELECT * FROM TBLDEUDORES WHERE " & Sq & " ORDER BY Baja"
End If

'Limipio la Lista
MSFlexGrid1.Rows = 0

Set rsDeu = Vada.OpenRecordset(sSql)
If (Not rsDeu.BOF) And (Not rsDeu.EOF) Then

With Me.MSFlexGrid1
.Rows = 1
.Cols = 7
.Row = 0
.Col = 0
.Text = "Nro."
.CellAlignment = 4
.ColWidth(.Col) = 600
.Col = 1
.FixedCols = 1


.Text = "Cuenta"
.CellAlignment = 7
.ColWidth(.Col) = 1050
.Col = 2

.Text = "Nombre y Apellido"
.CellAlignment = 4
.ColWidth(.Col) = 2555
.Col = 3

.Text = "Telefono"
.CellAlignment = 5
.ColWidth(.Col) = 1750
.Col = 4


.Text = "Documento"
.CellAlignment = 4
.ColWidth(.Col) = 1132
.Col = 5


.Text = "Estado de Cuenta"
.CellAlignment = 4
.ColWidth(.Col) = 2000
.Col = 6

.Text = "Localidad"
.CellAlignment = 4
.ColWidth(.Col) = 1900





'.Text = "Baja"
'.CellAlignment = 4
'.ColWidth(.Col) = 950


rsDeu.MoveLast
For Diez = 1 To rsDeu.RecordCount
If Diez = 1 Then
rsDeu.MoveFirst
Else
rsDeu.MoveNext
End If

.Rows = .Rows + 1
.Row = .Rows - 1
.Col = 0
.Text = Diez
.Col = 1
.Text = IIf(IsNull(rsDeu![cuenta]), " ", rsDeu![cuenta])
.Col = 2
.Text = IIf(IsNull(rsDeu![Apellido]), " ", rsDeu![Apellido])
.Col = 3
.Text = IIf(IsNull(rsDeu![Telefono]), " ", rsDeu![Telefono])
.Col = 4
.Text = IIf(IsNull(rsDeu![Documento]), " ", rsDeu![Documento])
.Col = 5
.Text = IIf(IsNull(rsDeu![estado]), " ", rsDeu![estado])
.Col = 6
.Text = IIf(IsNull(rsDeu![Domicilio]), " ", rsDeu![Domicilio])

'.Col = 7
'.Text = IIf(IsNull(rsDeu![Baja]), " ", rsDeu![Baja])
If Condi = "Text" Then
Me.Text4.Text = rsDeu!Apellido
' Me.txtbusqueda.Text = rsDeu!Nombre

Me.Text2.Text = IIf(IsNull(rsDeu![Documento]), " ", rsDeu![Documento])
Me.Text3.Text = IIf(IsNull(rsDeu![Telefono]), " ", rsDeu![Telefono])

'Me.Text2.Text = rsDeu!Documento
'Me.Text3.Text = rsDeu!Telefono
Me.Text1.Text = rsDeu!cuenta
Me.Combo4.Text = rsDeu!Nro_cart
End If
'.Text = Format(rsDeu![Saldo], "0.00")
If Diez = rsDeu.RecordCount Then Exit For
Next
.FixedRows = 1
End With

Else
MsgBox "Base de datos vacía.", vbApplicationModal + vbInformation, "Mensaje"
End If
rsDeu.Close
Set rsDeu = Nothing
End Sub

Private Function AgregarTexto(ByVal p_TextoOriginal As String, ByVal p_TextoNuevo As String) As String
Dim RES As String

On Error GoTo AgregarTexto_Error
'************************************************* **************************
RES = ""
If Trim(p_TextoOriginal) = "" Then
If Trim(p_TextoNuevo) <> "" Then
RES = "(" & p_TextoNuevo & ")"
End If
Else
If Trim(p_TextoNuevo) <> "" Then
RES = p_TextoOriginal & " AND (" & p_TextoNuevo & ")"
Else
RES = p_TextoOriginal
End If
End If
AgregarTexto = RES
'************************************************* **************************
On Error GoTo 0
Exit Function

AgregarTexto_Error:
AgregarTexto = RES
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure AgregarTexto of Formulario Form1"

End Function

Private Sub Form_Load()
CargarCombos





End Sub

Private Sub CargarCombos()
Dim rsem As Recordset
Dim rsLoc As Recordset
Dim q As Integer
Dim Pos As Long
Set rsem = Vada.OpenRecordset("empresa")
'###New
Combo1.Clear
Me.Combo1.AddItem "TODAS"
Combo1.ItemData(Combo1.NewIndex) = "0"

For q = 1 To rsem.RecordCount
Me.Combo1.AddItem rsem!id & " " & rsem!Nombre
Combo1.ItemData(Combo1.NewIndex) = rsem!id
rsem.MoveNext
Next q

Combo1.Text = "TODAS"

'Localidades
cboLocalidad.Clear
cboLocalidad.AddItem "TODAS"

Set rsLoc = Vada.OpenRecordset("select distinct(domicilio) from Tbldeudores order by domicilio")

If rsLoc.RecordCount = 0 Then
rsLoc.Close
Else

Do While Not rsLoc.EOF
cboLocalidad.AddItem Trim(rsLoc!Domicilio)
rsLoc.MoveNext
Loop
End If

cboLocalidad.Text = "TODAS"

' Me.Combo1.AddItem "Todas"
'rsem.Close
'Set rsem = Vada.OpenRecordset("tbldeudores")
'For q = 1 To rsem.RecordCount
' Me.Combo4.AddItem rsem!Nro_cart
' rsem.MoveNext

'Next q

rsem.Close

Combo4.Clear
Combo4.AddItem "TODAS"
Combo4.AddItem "1"
Combo4.AddItem "2"
Combo4.Text = "TODAS"

'Combo3.AddItem "Titularidad"
'Combo3.AddItem "Deuda"
'Combo3.AddItem "Todas"

'Estado
Combo2.Clear
Combo2.AddItem "Nuevos Propietarios"
Combo2.AddItem "TODOS"
Combo2.AddItem "Sucursal Martinez"
Combo2.AddItem "Alta Inicial"
Combo2.AddItem "Servicio"
Combo2.AddItem "Devolucion de Equipo"
Combo2.AddItem "Promesa de Pago"
Combo2.AddItem "Contactado"
Combo2.AddItem "Mensaje Contestador"
Combo2.AddItem "Baja"
Combo2.Text = "TODOS"
Combo2.AddItem "Cancelo deuda"



Combo5.Clear
Combo5.AddItem "TODAS"
Combo5.AddItem "Deuda"
Combo5.AddItem "Titularidad"
Combo5.Text = "TODAS"

MSFlexGrid1.Rows = 0
MSFlexGrid1.SelectionMode = flexSelectionByRow

Me.MSFlexGrid2.Visible = False
With Me.MSFlexGrid2
.Height = 2625
.Left = 4500
.Top = 4800
.Width = 6000
End With

End Sub


Private Sub Command1_Click()
Campo = "Estado"
cValor = Me.Combo2.Text
Condi = "Combo"
Call Cargargrid
grid1 = True

End Sub

Private Sub Form_Unload(Cancel As Integer)
Dim oFrm As Form

For Each oFrm In Forms
If UCase(oFrm.Name) <> "FORM1" Then
Unload oFrm
End If
Next

Set oFrm = Nothing

End Sub

Private Sub MSFlexGrid1_Click()

On Error GoTo MSFlexGrid1_Click_Error
'************************************************* ************************
If MSFlexGrid1.RowSel > 0 Then
Call Form2_Grid2
End If

'************************************************* ************************
On Error GoTo 0
Exit Sub

MSFlexGrid1_Click_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") en el procedimiento MSFlexGrid1_Click del Formulario Form1"
End Sub

Private Sub MSFlexGrid1_SelChange()
MSFlexGrid1.RowSel = MSFlexGrid1.Row
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
'If KeyAscii = 13 Then
'´´ Condi = "Text"
' ´ ' Campo = "cuenta"
'´´ ' cValor = Me.Text1.Text
' Call Cargargrid
'End If

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Condi = "Text"
Campo = "Documento"
cValor = Me.Text2.Text
Call Cargargrid
End If

End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Condi = "Text"
Campo = "telefono"
cValor = Me.Text3.Text
Call Cargargrid
End If

End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Condi = "Text"
Campo = "Apellido"
cValor = Me.Text4.Text
Call Cargargrid
End If
End Sub

Private Sub Text8_Change()

End Sub

Private Sub txtbusqueda_KeyPress(KeyAscii As Integer)
'If KeyAscii = 13 Then
' Condi = "Text"
' Campo = "nombre"
'cValor = Me.txtbusqueda.Text
' Call Cargargrid
'End If

End Sub
__________________
Hola mi nombre es Martin y me interesa mucho la programacion, en especial Visual Basic 6.0
Responder Con Cita
  #4 (permalink)  
Antiguo 31-03-2005, 22:46:18
Avatar de imported_chiaravel
Administrator
 
Registrado: dic 2002
Ubicación: Buenos Aires - Argentina
Posts: 2.281
imported_chiaravel Valoración +2
Predeterminado

Lo empiezo a leer y mañana cuando lo termine te digo que esta mal.

jaja

hombre.. es interminable....

Basicamente si quieres llenar un Combo con el contenido de una tabla, debes ...

1) Abrir la tabla y crear el Recordset con el filtro que tu quieres o sea con la sentencia SQL que quieras.

2) Limpiar el combo por datos anteriores que tuviera COMBO.CLEAR
3) Setear un texto al combo COMBO.TEXT="Selecciona"
4) hacer un.....

Código:
<nombre Recordset>.MoveFirst
Do until <nombre Recordset>.eof
     combo.additem <nombre Recordset>("campo")
     <nombre Recordset>.MoveNext
Loop
y LISTO !!!
Responder Con Cita
Respuesta


Herramientas
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Trackbacks are habilitado
Pingbacks are habilitado
Refbacks are habilitado


Temas Similares
Tema Autor Foro Respuestas Último Mensaje
como hacer consulta SQL en tiempo ejecucion garrulo Visual Basic.NET 2003 & 2005 5 10-11-2007 14:26:42
agregar codigo en tiempo de ejecucion trinado Visual Basic 6.00 11 04-04-2007 18:03:27
Seleccionar Base de Datos en tiempo de ejecucion??? joxkim Visual Basic.NET 2003 & 2005 0 11-10-2006 00:25:24
como dibujar en tiempo de ejecucion en vb_6.0 vb_koky Visual Basic 6.00 2 06-11-2004 10:03:20
Cambio de Base de Datos en Tiempo de Ejecucion sagc20 Crystal Reports 1 17-09-2004 01:00:00


La franja horaria es GMT. Ahora son las 23:25:24.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
A vBSkinworks Design

Alojado en el servicio Premium de Masquewebs | Diseño mejorado por MasqueWebs

right