Este es el codigo:
El error me lo da en la varialble en negritas y subrrayada
Código:
Es asunto es que me manda "Uso no valido de Null" y si tengo datos en la base de datos y la fecha es la correcta.Dim cn As New ADODB.Connection Private WithEvents rs As ADODB.Recordset Dim fechacz As Variant Dim horacz As Variant Dim totalc As String Dim totalfolios As Integer Dim usuario As String Private Sub CmdAceptar_Click() Set rs = New ADODB.Recordset cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=d:\respaldo\docs\base de datos\venta1.mdb" rs.Source = "Usuarios" rs.Source = "Usuderechos" rs.CursorType = adOpenKeyset rs.LockType = adLockOptimistic rs.Open "select * from usuarios, usuderechos where usuderechos.Id_Usuario = usuarios.Id_Usuario And usuarios.Id_Usuario = '" & TxtUsuario.Text & "' and usuarios.Contraseña = '" & TxtClave.Text & "' and usuderechos.Id_Usuario = '" & TxtUsuario.Text & "'", cn If rs.BOF = False And rs.EOF = False Then If rs.Fields("Corte_Z") = 1 Then rs.Close Set rs = New ADODB.Recordset rs.Source = "Venta" rs.CursorType = adOpenKeyset rs.LockType = adLockOptimistic fechacz = Date horacz = Time rs.Open "select CorteZ from Venta where CorteZ = '" & "S" & "'", cn If rs.EOF = False And rs.BOF = False Then MsgBox "El corte ya fue relizado" Unload Me cn.Close Else rs.Close rs.Open "select Sum(Total) As totalcz, Count(Folio) As folioscz from Venta where Fecha_Salida = #" & fechacz & "# and Status = '" & "CO" & "'", cn totalc = rs!totalcz totalc = FormatCurrency(totalc, 2) totalfolios = rs!folioscz rs.Close rs.Open "select * from Empresa, Venta", cn Printer.FontName = "Calibri" Printer.FontSize = 9 Printer.Print rs.Fields("Nombre") Printer.Print rs.Fields("Calle") Printer.Print "COL." & " " & rs.Fields("Colonia") & " " & "C.P." & " " & rs.Fields("Codigo_Postal") Printer.Print rs.Fields("Poblacion") & " " & rs.Fields("Estado") Printer.Print "TEL.:" & " " & rs.Fields("Telefono") & " " & "R.F.C.:" & " " & rs.Fields("RFC") Printer.Line (Printer.CurrentX, Printer.CurrentY)-(Printer.ScaleWidth, Printer.CurrentY) Printer.Print " " Printer.FontSize = 12 Printer.Print "TOTAL:" & " " & totalc Printer.Print " " Printer.Print "TOTAL FOLIOS:" & " " & totalfolios Printer.Print " " Printer.FontSize = 9 Printer.Print "FECHA" & " " & fechacz & " " & "HORA:" & " " & horacz 'Printer.EndDoc rs.Close rs.Open "select folio from venta where status = '" & "PE" & "'", cn rs.MoveFirst Printer.FontName = "Calibri" Printer.FontSize = 12 Printer.Print "PENDIENTES:" Do While rs.EOF = False Printer.Print " " & rs.Fields("Folio") rs.MoveNext Loop Printer.Print " " Printer.Print " " Printer.Print " " Printer.Print " " Printer.Print " " Printer.EndDoc rs.Close rs.Open "update venta set cortez = '" & "S" & "' where status = '" & "CO" & "'", cn rs.Open "select * from CorteZ", cn rs.MoveLast usuario = frmingreso.TxtUsuario.Text foliocz = rs.Fields("Folio_Cortez") + 1 rs.AddNew rs.Fields("Folio_Cortez") = foliocz rs.Fields("Total_CorteZ") = totalc rs.Fields("Id_Usuario") = usuario rs.Fields("Fecha_Corte") = fechacz rs.Fields("Cantidad_Folios") = totalfolios rs.Fields("Hora_Corte") = horacz rs.Update rs.Close cn.Close Unload Me End If Else MsgBox "No tiene derechos para imprimr el corte" rs.Close cn.Close TxtUsuario.SetFocus End If Else MsgBox "Usuario y/o Clave equivocado" cn.Close End If End Sub
Lo curioso es que ya habia hecho varias pruebas y funcionaba correctamente, ojala me puedan ayudar.
Muchas garcias de antemano