Problema para contar registros segun variable
Publicado por Miguel (6 intervenciones) el 28/05/2012 02:29:27
Hola amigos del foro por necesito preguntarles como puedo hacer para que en un textbox me muestre la cantidad de registros segun criterio ingresado en otros dos textbox ,tengo base de datos access 2000 y visual basic 6.0.les pongo el codigo para que lo vean.Muchas gracias.
Por favor donde esta el error.
Codigo completo
----------------------------------
Option Explicit
Dim cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Private Sub Command1_Click()
On Error GoTo error_Handler
Dim rst As New ADODB.Recordset
Dim ceemes As String
If cn.State = adStateOpen Then
ceemes = "SELECT Count(*) as Este_mes FROM Ingreso WHERE ProximoPago <= " & CDate(Text2) & "" And " & CDate(Text3) & """
Set rst = cn.Execute(ceemes, , adCmdText)
Text1.Text = rst("Este_mes")
Set rst = Nothing
End If
Exit Sub
error_Handler:
MsgBox Err.Description, vbCritical
End Sub
Private Sub Form_Load()
Set cn = New ADODB.Connection
With cn
Dim path_bd As String
path_bd = "C:\Documents and Settings\mike\Escritorio\P3\db1.mdb"
.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & path_bd & ";" & "Persist Security Info=False"
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Not cn Is Nothing Then
If cn.State = adStateOpen Then cn.Close
Set cn = Nothing
End If
End Sub
Por favor donde esta el error.
Codigo completo
----------------------------------
Option Explicit
Dim cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Private Sub Command1_Click()
On Error GoTo error_Handler
Dim rst As New ADODB.Recordset
Dim ceemes As String
If cn.State = adStateOpen Then
ceemes = "SELECT Count(*) as Este_mes FROM Ingreso WHERE ProximoPago <= " & CDate(Text2) & "" And " & CDate(Text3) & """
Set rst = cn.Execute(ceemes, , adCmdText)
Text1.Text = rst("Este_mes")
Set rst = Nothing
End If
Exit Sub
error_Handler:
MsgBox Err.Description, vbCritical
End Sub
Private Sub Form_Load()
Set cn = New ADODB.Connection
With cn
Dim path_bd As String
path_bd = "C:\Documents and Settings\mike\Escritorio\P3\db1.mdb"
.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & path_bd & ";" & "Persist Security Info=False"
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Not cn Is Nothing Then
If cn.State = adStateOpen Then cn.Close
Set cn = Nothing
End If
End Sub
Valora esta pregunta


0