Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Hacer mas de 1 recordset de una misma tabla de acces para formulario Excel

publicado

Saludos, quisiera que me ayuden respecto a un problema que tengo con un reporte.

Tengo una tabla que contiene las siguientes donde almaceno la siguiente información: Fecha 1, pago 1, fecha 2, pago 2, fecha 3 y pago 3
Lo que necesito es que en un formulario en excel de consulta que tengo, en base a 2 textbox colocar el rango de fechas y haga la consulta en la base de datos de acuerdo a las columnas fecha 1, fecha 2 y fecha 3 y jale al listbox los datos de pagos 1, 2 y 3.

Esta es mi macro, pero solo hace consulta con la fecha 1

Agradezco de antemano su apoyo

Sub Consultacaja()
Call Conexion.Abrir_Rs
sql = "SELECT Correlativo, C_1, C_2, C_5, C_6, C_7, C_8, C_9, C_10, C_11, C_13, C_14, RUC, Resp FROM Tb_Registros  " & _
" WHERE C_2 Like '%" & UCase(Trim(Cmb_Suc)) & "%' AND C_1 BETWEEN #" & Format(CDate(Txt_FechaInicial.Value), "mm/dd/yyyy") & "# AND #" & Format(CDate(Txt_FechaFinal.Value), "mm/dd/yyyy") & "#"

rs.Open sql, cnn, 1, 1
'Rs.Open SQL, Cnn
If rs.RecordCount > 0 Then
With Me.ListBox1
.ColumnCount = 13  'Cantidad de columnas = cantidad de TextBoxes
.List = [A5:o5].Value 'Rango de datos "temporal" para que se cargue en el ListBox
.Clear
Do While rs.EOF = False
.AddItem
.List(.ListCount - 1, 0) = rs!Correlativo 'recibo
.List(.ListCount - 1, 1) = CDate(rs!C_1) 'fecha
.List(.ListCount - 1, 2) = rs!C_2 'tipo
.List(.ListCount - 1, 3) = rs!C_7 'tipo de ingreso
.List(.ListCount - 1, 4) = rs!RUC 'RUC
.List(.ListCount - 1, 5) = rs!C_8 'cliente
.List(.ListCount - 1, 6) = FormatNumber(rs!C_9, 2) 'total
.List(.ListCount - 1, 7) = FormatNumber(rs!C_10, 2) 'comision
.List(.ListCount - 1, 8) = FormatNumber(rs!C_13, 2) 'PAGO
.List(.ListCount - 1, 9) = FormatNumber(rs!C_14, 2) 'saldo pendiente
.List(.ListCount - 1, 10) = rs!C_6 'medio de pago
.List(.ListCount - 1, 11) = rs!C_5 'jalador
.List(.ListCount - 1, 12) = rs!Resp 'USUARIO

rs.MoveNext
Loop
'ListBox1.ColumnCount = 13
ListBox1.ColumnWidths = "55;55;50;60;60;90;50;50;50;50;55;50;50"
Txt_Registros.Text = ListBox1.ListCount
End With
Else
ListBox1.Clear
End If
Call Conexion.Cerrar_Rs
End Sub
 

Featured Replies

publicado
  • Autor
Hace 3 horas, CARLOS_11 dijo:

Saludos, quisiera que me ayuden respecto a un problema que tengo con un reporte.

Tengo una tabla que contiene las siguientes donde almaceno la siguiente información: Fecha 1, pago 1, fecha 2, pago 2, fecha 3 y pago 3
Lo que necesito es que en un formulario en excel de consulta que tengo, en base a 2 textbox colocar el rango de fechas y haga la consulta en la base de datos de acuerdo a las columnas fecha 1, fecha 2 y fecha 3 y jale al listbox los datos de pagos 1, 2 y 3.

Esta es mi macro, pero solo hace consulta con la fecha 1

Agradezco de antemano su apoyo

Sub Consultacaja()
Call Conexion.Abrir_Rs
sql = "SELECT Correlativo, C_1, C_2, C_5, C_6, C_7, C_8, C_9, C_10, C_11, C_13, C_14, RUC, Resp FROM Tb_Registros  " & _
" WHERE C_2 Like '%" & UCase(Trim(Cmb_Suc)) & "%' AND C_1 BETWEEN #" & Format(CDate(Txt_FechaInicial.Value), "mm/dd/yyyy") & "# AND #" & Format(CDate(Txt_FechaFinal.Value), "mm/dd/yyyy") & "#"

rs.Open sql, cnn, 1, 1
'Rs.Open SQL, Cnn
If rs.RecordCount > 0 Then
With Me.ListBox1
.ColumnCount = 13  'Cantidad de columnas = cantidad de TextBoxes
.List = [A5:o5].Value 'Rango de datos "temporal" para que se cargue en el ListBox
.Clear
Do While rs.EOF = False
.AddItem
.List(.ListCount - 1, 0) = rs!Correlativo 'recibo
.List(.ListCount - 1, 1) = CDate(rs!C_1) 'fecha
.List(.ListCount - 1, 2) = rs!C_2 'tipo
.List(.ListCount - 1, 3) = rs!C_7 'tipo de ingreso
.List(.ListCount - 1, 4) = rs!RUC 'RUC
.List(.ListCount - 1, 5) = rs!C_8 'cliente
.List(.ListCount - 1, 6) = FormatNumber(rs!C_9, 2) 'total
.List(.ListCount - 1, 7) = FormatNumber(rs!C_10, 2) 'comision
.List(.ListCount - 1, ? = FormatNumber(rs!C_13, 2) 'PAGO
.List(.ListCount - 1, 9) = FormatNumber(rs!C_14, 2) 'saldo pendiente
.List(.ListCount - 1, 10) = rs!C_6 'medio de pago
.List(.ListCount - 1, 11) = rs!C_5 'jalador
.List(.ListCount - 1, 12) = rs!Resp 'USUARIO

rs.MoveNext
Loop
'ListBox1.ColumnCount = 13
ListBox1.ColumnWidths = "55;55;50;60;60;90;50;50;50;50;55;50;50"
Txt_Registros.Text = ListBox1.ListCount
End With
Else
ListBox1.Clear
End If
Call Conexion.Cerrar_Rs
End Sub
 

 

PRUEBA.rar

publicado

Aquí ya es hora de cenar, si no te contesta nadie esta noche, mañana le echo un vistazo.

publicado
  • Autor

vale gracias, el formulario es FormConsultaCaja

publicado

Así me ha funcionado:

sql = "SELECT Correlativo, C_1, C_2, C_5, C_6, C_7, C_8, C_9, C_10, C_11, C_13, C_14, RUC, Resp FROM Tb_Registros  " & _
      " WHERE C_2 Like '*" & UCase(Trim(Cmb_Suc)) & "*' AND C_1 BETWEEN #" & _
              Format(CDate(Txt_FechaInicial.Value), "mm/dd/yyyy") & "# AND #" & _
              Format(CDate(Txt_FechaFinal.Value), "mm/dd/yyyy") & "#"

 

publicado
Ahora mismo, Antoni dijo:

Así me ha funcionado, solo he sustituido % por *:

sql = "SELECT Correlativo, C_1, C_2, C_5, C_6, C_7, C_8, C_9, C_10, C_11, C_13, C_14, RUC, Resp FROM Tb_Registros  " & _
      " WHERE C_2 Like '*" & UCase(Trim(Cmb_Suc)) & "*' AND C_1 BETWEEN #" & _
              Format(CDate(Txt_FechaInicial.Value), "mm/dd/yyyy") & "# AND #" & _
              Format(CDate(Txt_FechaFinal.Value), "mm/dd/yyyy") & "#"

 

 

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.