este es mi codigo oki en la cual da el primer cuadro de un listview y puedo editar algunos datos
este cuadro se llama frmeditclau
Option Explicit
Enum EACCION
AGREGAR_REGISTRO = 0
editar_registro = 1
End Enum
Public IdRegistro
Public ACCION As EACCION
Private Sub ChameleonBtn1_Click()
frmImpresionCIT3.Show
frmImpresionCIT3.Text1(0) = Text1(4)
frmImpresionCIT3.Text1(1) = Text1(8)
frmImpresionCIT3.Text1(2) = Text1(2)
frmImpresionCIT3.Text1(18) = Text1(15)
frmImpresionCIT3.Text1(19) = Text1(16)
frmImpresionCIT3.Text1(27) = Text1(17)
End Sub
Private Sub ChameleonBtn2_Click()
frmImpresionCIT7.Show
frmImpresionCIT7.Text1(0) = Text1(2)
frmImpresionCIT7.Text1(5) = Text1(16)
frmImpresionCIT7.Text1(6) = Text1(15)
frmImpresionCIT7.Text1(31) = Text1(17)
End Sub
Private Sub ChameleonBtn3_Click()
frmImpresionCIT4.Show
frmImpresionCIT4.Text1(0) = Text1(4)
frmImpresionCIT4.Text1(1) = Text1(8)
frmImpresionCIT4.Text1(2) = Text1(2)
frmImpresionCIT4.Text1(18) = Text1(15)
frmImpresionCIT4.Text1(19) = Text1(16)
frmImpresionCIT4.Text1(27) = Text1(17)
frmImpresionCIT4.Text1(26) = Text1(13)
End Sub
Private Sub ChameleonBtn4_Click()
frmImpresionCIT8.Show
End Sub
Private Sub ChameleonBtn5_Click()
frmImpresionCIT6.Show
End Sub
Private Sub ChameleonBtn6_Click()
frmImpresionCIT9.Show
End Sub
Private Sub ChameleonBtn7_Click()
frmImpresionCIT10.Show
End Sub
Private Sub ChameleonBtn8_Click()
frmImpresionCIT11.Show
End Sub
Private Sub ChameleonBtn9_Click()
frmImpresionCIT12.Show
End Sub
Private Sub cmdGuardar_Click()
Text1(11).Text = ((Val(Text1(9).Text) * Val(Text1(10).Text)))
Text1(22).Text = ((Val(Text1(11).Text * 0.3) / 1.19))
Dim sqlDate As String
sqlDate = Format(Date, "YYYY/MM/DD")
On Error GoTo ErrorSub
' Valida el codigo de barra que no este vacio
'''''''''''''''''''''''''''''''''''''''''''''
If Trim(Text1(12)) = "" Then
MsgBox "El Nº de Codigo de Barra no puede estar vacio", vbCritical, "Datos incompletos"
Text1(12).SetFocus
Exit Sub
' Valida el cit
''''''''''''''''''''''''''''''''
ElseIf Trim(Text1(13)) = "" Then
MsgBox "El Nº CIT no puede estar vacio", vbCritical, "Datos incompletos"
Text1(13).SetFocus
Exit Sub
' Valida la placa
''''''''''''''''''''''''''''''''
ElseIf Trim(Text1(2)) = "" Then
MsgBox "No se ha indicado el Nº de Placa", vbCritical, "Datos incompletos"
Text1(14).SetFocus
Exit Sub
' Valida el nº de motor
''''''''''''''''''''''''''''''''
ElseIf Trim(Text1(15)) = "" Then
MsgBox "No se ha indicado el Nº de Motor", vbCritical, "Datos incompletos"
Text1(15).SetFocus
Exit Sub
' Valida el nº de serie o chasis
'''''''''''''''''''''''''''''''''''''
ElseIf Trim(Text1(16)) = "" Then
MsgBox "No se ha indicado el Nº de Serie o Chasis", vbCritical, "Datos incompletos"
Text1(16).SetFocus
Exit Sub
' Valida el nº de certificado
'''''''''''''''''''''''''''''''''''''
ElseIf Trim(Text1(17)) = "" Then
MsgBox "No se ha indicado el Nº de Certificado", vbCritical, "Datos incompletos"
Text1(17).SetFocus
Exit Sub
End If
'Agrega el registro
'''''''''''''''''''''''''''''''
Select Case ACCION
Case editar_registro
CNN.Execute "UPDATE Clientes set voucher = '" & Text1(14) & _
"', contacto = '" & Text1(3) & _
"', razonsocial = '" & Text1(4) & _
"', nºderuc = '" & Text1(7) & _
"', direccion = '" & Text1(8) & _
"', inspector = '" & Text1(5) & _
"', tipodecertificado = '" & Text1(6) & _
"', cantidad = '" & Text1(9) & _
"', precio = '" & Text1(10) & _
"', total= '" & Text1(11) & _
"', codigodebarra = '" & Text1(12) & _
"', cit = '" & Text1(13) & _
"', nºdeplaca = '" & Text1(2) & _
"', nºdemotor = '" & Text1(15) & _
"', nºdeserieochasis = '" & Text1(16) & _
"', nºdecertificado = '" & Text1(17) & _
"', totalvoucher = '" & Text1(18) & _
"', boletaofactura = '" & Text1(19) & _
"', mes = '" & Text1(20) & _
"', lista = '" & Text1(21) & _
"', asignacion = '" & Text1(22) & _
"', observacion = '" & Text1(23) & _
"' where Cod = " & IdRegistro & ""
Case AGREGAR_REGISTRO
CNN.Execute "INSERT INTO Clientes (voucher, dia, contacto, razonsocial, nºderuc, direccion, inspector, tipodecertificado, cantidad, precio, total, codigodebarra, cit, nºdeplaca, nºdemotor, nºdeserieochasis, nºdecertificado, totalvoucher, boletaofactura, mes, lista, asignacion, observacion) VALUES('" & Text1(14) & "','" & sqlDate & "','" & Text1(3) & "','" & Text1(4) & "','" & Text1(7) & "','" & Text1(8) & "','" & Text1(5) & "','" & Text1(6) & "','" & Text1(9) & "','" & Text1(10) & "','" & Text1(11) & "','" & Text1(12) & "','" & Text1(13) & "','" & Text1(2) & "','" & Text1(15) & "','" & Text1(16) & "','" & Text1(17) & "','" & Text1(18) & "','" & Text1(19) & "','" & Text1(20) & "','" & Text1(21) & "','" & Text1(22) & "','" & Text1(23) & "')"
End Select
rs.Requery 1
Call CargarListView(FrmPrincipalClau.LV, rs)
DoEvents
Unload Me
Set FrmEditClau = Nothing
Exit Sub
ErrorSub:
MsgBox Err.Description
End Sub
Private Sub cmdCancelar_Click()
Unload Me
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then
Unload Me
End If
End Sub
Private Sub Text1_Change(Index As Integer)
Text1(22) = Format(Text1(22), "#0.00")
Text1(11) = Format(Text1(11), "#0.00")
Text1(18) = Format(Text1(18), "#0.00")
End Sub
Private Sub Timer1_Timer()
If FrmEditClau.Caption = "[ Editar registro - Claudia ] [ INSTITUTO DE TRANSPORTES UNAC ]" Then
FrmEditClau.Caption = "[ INSTITUTO DE TRANSPORTES UNAC ]"
Else: FrmEditClau.Caption = "[ Editar registro - Claudia ] [ INSTITUTO DE TRANSPORTES UNAC ]"
End If
End Sub
y este es un cuadro de los 7 q tngo para agregar datos diferentes
este cuadro se activa cuando aprieto ChameleonBtn1 el cuadro se llama frmimpresioncit3
Option Explicit
Dim CNN As New ADODB.Connection
Public ACCION As EACCION
Dim rs As New ADODB.Recordset
Dim RSLoquequieras As ADODB.Recordset
Public IdRegistro
Private Sub Check1_Click()
Text2.Text = ("x")
Text3.Text = (" ")
Text4.Text = (" ")
End Sub
Private Sub Check2_click()
Text3.Text = ("x")
Text2.Text = (" ")
Text4.Text = (" ")
End Sub
Private Sub Check3_Click()
Text4.Text = ("x")
Text2.Text = (" ")
Text3.Text = (" ")
End Sub
Private Sub Command1_Click()
Call Imprimir
End Sub
'Connection Confirmation
Private Sub Form_Load()
' establece la cadena de conexión a utilizar en la propiedad ConnectionString
CNN.ConnectionString = "Provider=SQLOLEDB.1;Password=qweqwe;Persist Security Info=True;User ID=omar;Initial Catalog=BASEFINAL;Data Source=SERVIDOR"
' abre la base de datos
CNN.Open
' Abre el recordset enviando la consulta sql
rs.Open "Select * from clientes", CNN, adOpenDynamic, adLockOptimistic
' muestra los datos en los text
Command1.Enabled = False
End Sub
Private Sub cmdSave_Click()
Select Case ACCION
Case editar_registro
CNN.Execute "UPDATE Clientes set razonsocial = '" & Text1(0) & "', direccion = '" & Text1(1) & "', nºdeplaca = '" & Text1(2) & "', marca = '" & Text1(3) & "', modelo = '" & Text1(4) & "', carroceria = '" & Text1(5) & "', colores = '" & Text1(6) & "', nºcilindros = '" & Text1(7) & "', pesoneto = '" & Text1(8) & "', cargautil = '" & Text1(9) & "', pesobruto = '" & Text1(10) & "', longitud = '" & Text1(11) & "', ancho = '" & Text1(12) & "', altura = '" & Text1(13) & "', clase = '" & Text1(14) & _
"', añofabrica = '" & Text1(15) & "', combustible = '" & Text1(16) & "', nºejes = '" & Text1(17) & "', nºdemotor = '" & Text1(18) & "', nºdeserieochasis = '" & Text1(19) & "', nºpasajeros = '" & Text1(20) & "', nºasientos = '" & Text1(21) & "', nºruedas = '" & Text1(22) & "', formula = '" & Text1(23) & "', categoria = '" & Text1(24) & "', potencia = '" & Text1(25) & "', detalle1 = '" & Text1(28) & "', detalle2 = '" & Text1(29) & "', fecha = '" & Text1(30) & "', modificacion = '" & Text2 & "', montaje = '" & Text3 & "', fabricacion = '" & Text4 & _
"' where Cod = " & IdRegistro & ""
End Select
rs.Requery 1
DoEvents
Set FrmEditClau = Nothing
Exit Sub
ErrorSub:
MsgBox Err.Description
End Sub
Private Sub Imprimir()
Dim rsFicha As ADODB.Recordset
Set rsFicha = New Recordset
rsFicha.Open "Select * FROM clientes Where Cod=" & Text15, CNN, adOpenStatic, adLockReadOnly
If rsFicha.RecordCount > 0 Then
Set DataReport1.DataSource = rsFicha
DataReport1.Show
Else
MsgBox "No hay registro para imprimir ", vbInformation
End If
Unload Me
End Sub
Private Sub desabilitaText()
Text1(0).Enabled = False
Text1(1).Enabled = False
Text1(2).Enabled = False
Text1(3).Enabled = False
Text1(4).Enabled = False
Text1(5).Enabled = False
Text1(6).Enabled = False
Text1(7).Enabled = False
Text1(8).Enabled = False
Text1(9).Enabled = False
Text1(10).Enabled = False
Text1(11).Enabled = False
Text1(12).Enabled = False
Text1(13).Enabled = False
Text1(14).Enabled = False
Text1(15).Enabled = False
Text1(16).Enabled = False
Text1(17).Enabled = False
Text1(18).Enabled = False
Text1(19).Enabled = False
Text1(20).Enabled = False
Text1(21).Enabled = False
Text1(22).Enabled = False
Text1(23).Enabled = False
Text1(24).Enabled = False
Text1(25).Enabled = False
Text1(28).Enabled = False
Text1(29).Enabled = False
Text1(30).Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
End Sub
' botón que mueve al primer previo
'''''''''''''''''''''''''''''''''''''''''''''''
Private Sub cmdMoveFirst_Click()
rs.MoveFirst
' Visualiza los datos en los textbox
Call Visualizar_Datos
End Sub
' botón que se desplaza al último registro
'''''''''''''''''''''''''''''''''''''''''''''''
Private Sub cmdMoveLast_Click()
' Ejecuta MoveLast y se posiciona en el último registro
rs.MoveLast
' Visualiza los datos en los textbox
Call Visualizar_Datos
End Sub
' Botón para el siguiente
'''''''''''''''''''''''''''''''''''''''''''''
Private Sub cmdMoveNext_Click()
rs.MoveNext
' Si no sobrepasó el final del recordset ...
If rs.EOF Then
' se posiciona en el ultimo
rs.MoveLast
MsgBox " Se está en el ultimo registro ", vbInformation
Else
' Visualiza los datos en los text box
Call Visualizar_Datos
End If
End Sub
' Command para ir al registro previo
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub cmdMovePrevious_Click()
rs.MovePrevious
' si el recordset sobrepasó el comienzo se posiciona en el primero
If rs.BOF Then
rs.MoveFirst
MsgBox " este es el Primer registro ", vbInformation, " Primer registro"
Else
' Carga los datos
Call Visualizar_Datos
End If
End Sub
Private Sub visualizar()
Text15.Text = CLng(rs("cod"))
End Sub
Private Sub Visualizar_Datos()
Text15.Text = CLng(rs("cod"))
End Sub