| |||
![]() Soy nuevo en esto de Vb, estoy haciendo un sistema en vb 6.0, utilizo sql server, hago el enlace mediante un adodc1, como le puedo hacer para que en un inputbox ingrese el numero de idetificacion de algun cliente y una vez que lo encuentre me envie todos sus datos a sus respectivos textbox, si alguien tiene el codigo para eso, se lo agradecere mucho, ya pase buen rato tratando de hacer esto y no sale |
| |||
respuesta hola no te puedo explicar el codigo completo pero aqui tienes un ejemplo trabajo con ado preo to creo las conexiones es decir no utilizo el control adodc1 si no que hago lo siguiente dim conexion as adodb.conexion dim rs as adodb.recordset etc. bueno aqui te paso el codigo Private Sub Command3_Click() Dim rsgeneral As ADODB.Recordset dim numerocontrol as string numcontrol = InputBox("Introduce el numero de control") If numcontrol = "" Then Exit Sub Else conexion'aqui es donde llamo mo conexion me imagino que solo tienes que modificar esto y poner tucontrol adodc1 Set rsnumero = New ADODB.Recordset rsnumero.Open "SELECT *FROM registrardatos", con, adOpenDynamic, adLockReadOnly rsnumero.Filter = "[numcontrol]='" & numcontrol & "'" Set rsgeneral = rsnumero If rsnumero.EOF Then MsgBox "El Numero" & vbCrLf & "[ " & numcontrol & " ]" & vbCrLf & " no fue localizado.", vbCritical Exit Sub Else Text1 = IIf(IsNull(rsgeneral("nombres")), "Campo sin Registro", Trim(rsgeneral("nombres"))) Text2 = IIf(IsNull(rsgeneral("carrera")), "Campo sin Registro", Trim(rsgeneral("carrera"))) Text3 = IIf(IsNull(rsgeneral("escuela")), "Campo sin Registro", Trim(rsgeneral("escuela"))) Text4 = IIf(IsNull(rsgeneral("direscuela")), "Campo sin Registro", Trim(rsgeneral("direscuela"))) Text5 = IIf(IsNull(rsgeneral("director")), "Campo sin Registro", Trim(rsgeneral("director"))) Text6 = IIf(IsNull(rsgeneral("objetoservicio")), "Campo sin Registro", Trim(rsgeneral("objetoservicio"))) Text7 = IIf(IsNull(rsgeneral("actividades")), "Campo sin Registro", Trim(rsgeneral("actividades"))) Text8 = IIf(IsNull(rsgeneral("dependencia")), "Campo sin Registro", Trim(rsgeneral("dependencia"))) Text9 = IIf(IsNull(rsgeneral("dirdepen")), "Campo sin Registro", Trim(rsgeneral("dirdepen"))) Text10 = IIf(IsNull(rsgeneral("unidadad")), "Campo sin Registro", Trim(rsgeneral("unidadad"))) Text11 = IIf(IsNull(rsgeneral("responsable")), "Campo sin Registro", Trim(rsgeneral("responsable"))) Text12 = IIf(IsNull(rsgeneral("cargoresponsable")), "Campo sin Registro", Trim(rsgeneral("cargoresponsable"))) Text13 = IIf(IsNull(rsgeneral("diasprestacion")), "Campo sin Registro", Trim(rsgeneral("diasprestacion"))) Text14 = IIf(IsNull(rsgeneral("finicio")), "Campo sin Registro", Trim(rsgeneral("finicio"))) Text15 = IIf(IsNull(rsgeneral("ftermino")), "Campo sin Registro", Trim(rsgeneral("ftermino"))) Text16 = IIf(IsNull(rsgeneral("fregistro")), "Campo sin Registro", Trim(rsgeneral("fregistro"))) Text17 = IIf(IsNull(rsgeneral("horario")), "Campo sin Registro", Trim(rsgeneral("horario"))) Text18 = IIf(IsNull(rsgeneral("programa")), "Campo sin Registro", Trim(rsgeneral("programa"))) Text19 = IIf(IsNull(rsgeneral("semestre")), "Campo sin Registro", Trim(rsgeneral("semestre"))) Text20 = IIf(IsNull(rsgeneral("horas")), "Campo sin Registro", Trim(rsgeneral("horas"))) Text21 = IIf(IsNull(rsgeneral("numcontrol")), "Campo sin Registro", Trim(rsgeneral("numcontrol"))) End If Exit Sub End If End Sub |
| |||
ya que si lo que te mando no te funciona esto esta comprobado siempre y cuando tu conexion este bien hecha aqui te va el codigo claro no como lo quiere modifica Dim existe As String Dim nombre As String nombre = inoutbox(nombre) If nombre = "" Then Exit Sub Else Adodc1.RecordSource = "SELECT *FROM busqueda WHERE nombres = '" & nombre & "'" Adodc1.Refresh With Adodc1.Recordset 'si no encuentra If .RecordCount = 0 Then txtcarrera.SetFocus Exit Sub Else 'si encuentra registro 'Text1 = !nombres existe = MsgBox("Ya Existe un alumno con ese nombre" & vbCrLf _ & " Desea Consultar sus datos", vbInformation + vbYesNo) If existe = vbYes Then txtnombre = !nombre txtpaterno = !paterno txtmaterno = !materno txtcarrera = !carrera Cmbescuela = !escuela 'txtescuela = !escuela txtdirescuela = !direscuela txtdirector = !director txtobjetivo = !objetoservicio txtactividades = !actividades txtdependencia = !dependencia txtdirdependencia = !dirdepen txtunidad = IIf(!unidadad = "", "No Registrado", !unidadad) txtresponsable = !responsable txtcargo = !cargoresponsable ' = IIf(txtcargo = "", "No Proporcionado por el usuario", txtcargo) txtdias = !diasprestacion ' = IIf(txtdias = "", "No Proporcionado por el usuario", txtdias) Finicio = !Finicio 'txtinicio = !Finicio ' = IIf(Finicio = "", "No Proporcionado por el usuario", Finicio) Ftermino = !Ftermino ' = IIf(Ftermino = "", "No Proporcionado por el usuario", Ftermino) Fentrega = !Fentrega ' = IIf(Fentrega = "", "No Proporcionado por el usuario", Fentrega) '!Ftermino = IIf(Ftermino = "", "No Proporcionado por el usuario", Ftermino) 'txtregistro = !Fregistro '= IIf(Label9.Caption = "", "No Proporcionado por el usuario", Label9.Caption) txthorario = !horario Cmbprograma = !programa ' = IIf(Cmbprograma = "", "No Proporcionado por el usuario", Cmbprograma) Cmbsemestre = !semestre '= IIf(Cmbsemestre = "", "No Proporcionado por el usuario", Cmbsemestre) Cmbhoras = !horas '= IIf(Cmbhoras = "", "No Proporcionado por el usuario", Cmbhoras) txtnumero = !numcontrol ' = IIf(txtnumero = "", "No Proporcionado por el usuario", txtnumero) numeroeliminar = Trim(txtnumero) Label30.Caption = !numero Option1.Enabled = False Option2.Enabled = False Tool.Buttons(1).Enabled = False Exit Sub Else 'MsgBox "Presiono NO" Exit Sub End If Exit Sub End If End With End If 'espero por lo menos me digas si te funciono |
| |||
Cita: me marca error en el objeto adodc1 y el metodo refresh, ademas cuando introduzco un registro invalido tambien me dice que existe y si quiero ver sus datos, otra es cuando introduzco un registro valido al darle la opcion de ver sus datos no los manda a sus respectivos textbox
Iniciado por xochitemol siempre y cuando tu conexion este bien hecha aqui te va el codigo claro no como lo quiere modifica Dim existe As String Dim nombre As String nombre = inoutbox(nombre) If nombre = "" Then Exit Sub Else Adodc1.RecordSource = "SELECT *FROM busqueda WHERE nombres = '" & nombre & "'" Adodc1.Refresh With Adodc1.Recordset 'si no encuentra If .RecordCount = 0 Then txtcarrera.SetFocus Exit Sub Else 'si encuentra registro 'Text1 = !nombres existe = MsgBox("Ya Existe un alumno con ese nombre" & vbCrLf _ & " Desea Consultar sus datos", vbInformation + vbYesNo) If existe = vbYes Then txtnombre = !nombre txtpaterno = !paterno txtmaterno = !materno txtcarrera = !carrera Cmbescuela = !escuela 'txtescuela = !escuela txtdirescuela = !direscuela txtdirector = !director txtobjetivo = !objetoservicio txtactividades = !actividades txtdependencia = !dependencia txtdirdependencia = !dirdepen txtunidad = IIf(!unidadad = "", "No Registrado", !unidadad) txtresponsable = !responsable txtcargo = !cargoresponsable ' = IIf(txtcargo = "", "No Proporcionado por el usuario", txtcargo) txtdias = !diasprestacion ' = IIf(txtdias = "", "No Proporcionado por el usuario", txtdias) Finicio = !Finicio 'txtinicio = !Finicio ' = IIf(Finicio = "", "No Proporcionado por el usuario", Finicio) Ftermino = !Ftermino ' = IIf(Ftermino = "", "No Proporcionado por el usuario", Ftermino) Fentrega = !Fentrega ' = IIf(Fentrega = "", "No Proporcionado por el usuario", Fentrega) '!Ftermino = IIf(Ftermino = "", "No Proporcionado por el usuario", Ftermino) 'txtregistro = !Fregistro '= IIf(Label9.Caption = "", "No Proporcionado por el usuario", Label9.Caption) txthorario = !horario Cmbprograma = !programa ' = IIf(Cmbprograma = "", "No Proporcionado por el usuario", Cmbprograma) Cmbsemestre = !semestre '= IIf(Cmbsemestre = "", "No Proporcionado por el usuario", Cmbsemestre) Cmbhoras = !horas '= IIf(Cmbhoras = "", "No Proporcionado por el usuario", Cmbhoras) txtnumero = !numcontrol ' = IIf(txtnumero = "", "No Proporcionado por el usuario", txtnumero) numeroeliminar = Trim(txtnumero) Label30.Caption = !numero Option1.Enabled = False Option2.Enabled = False Tool.Buttons(1).Enabled = False Exit Sub Else 'MsgBox "Presiono NO" Exit Sub End If Exit Sub End If End With End If 'espero por lo menos me digas si te funciono |