Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

"""msgbox no hay datos"""

Estas en el tema de """msgbox no hay datos""" en el foro de Visual Basic clásico en Foros del Web. buenos dias estoy realizando consultas atravz de una aplicacion que hice cuando consulto lo hace muy bine pero yo necesito lanzar un msgbox cuando los ...
  #1 (permalink)  
Antiguo 21/06/2007, 08:57
 
Fecha de Ingreso: abril-2007
Mensajes: 88
Antigüedad: 17 años
Puntos: 0
De acuerdo """msgbox no hay datos"""

buenos dias estoy realizando consultas atravz de una aplicacion que hice cuando consulto lo hace muy bine pero yo necesito lanzar un msgbox cuando los datos no esten en la base de datos el codigo que tengo es




Set con = CreateObject("ADODB.Connection")
con.Open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & "F:\Proyecto roaming global\Base.mdb")

busca = Text9.Text
SQL = "SELECT * FROM AGREGAR WHERE SERIAL LIKE '" & busca & "'"
Set RS = con.Execute(SQL)
Do While Not RS.EOF
Text13.Text = Text13.Text & RS("SIMCARD")
Text14.Text = Text14.Text & RS("EQUIPO")
Text15.Text = Text15.Text & RS("MARCA")
Text16.Text = Text16.Text & RS("MODELO")
Text17.Text = Text17.Text & RS("BATERIA")
Text18.Text = Text18.Text & RS("CARGADOR")
Text19.Text = Text19.Text & RS("CLIENTE")
Text20.Text = Text20.Text & RS("CEDULA")
Text21.Text = Text21.Text & RS("NUMERODETELEFONO")
Text22.Text = Text22.Text & RS("ENTREGADOPOR")
Text23.Text = Text23.Text & RS("RECIBIDOPOR")
Text24.Text = Text24.Text & RS("FECHA")
Text8.Text = Text8.Text & RS("EQUIPOEN")
RS.MoveNext
Loop
  #2 (permalink)  
Antiguo 21/06/2007, 15:02
Avatar de Kruzado  
Fecha de Ingreso: marzo-2007
Mensajes: 307
Antigüedad: 17 años, 2 meses
Puntos: 17
Re: """msgbox no hay datos"""

prueba esto

on error resume next 'LINEA NUEVA

Set con = CreateObject("ADODB.Connection")
con.Open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & "F:\Proyecto roaming global\Base.mdb")

busca = Text9.Text
SQL = "SELECT * FROM AGREGAR WHERE SERIAL LIKE '" & busca & "'"
Set RS = con.Execute(SQL)
rs.movefirst 'LINEA NUEVA KE FUERZA LA CAIDA DEL PROGRAMA CUANDO NO HAY REGISTROS
if err.number <> 0 then 'SI NO TIENE REGISTROS ENTRA POR ACA
msgbox "no hay datos"
else
Do While Not RS.EOF
Text13.Text = Text13.Text & RS("SIMCARD")
Text14.Text = Text14.Text & RS("EQUIPO")
Text15.Text = Text15.Text & RS("MARCA")
Text16.Text = Text16.Text & RS("MODELO")
Text17.Text = Text17.Text & RS("BATERIA")
Text18.Text = Text18.Text & RS("CARGADOR")
Text19.Text = Text19.Text & RS("CLIENTE")
Text20.Text = Text20.Text & RS("CEDULA")
Text21.Text = Text21.Text & RS("NUMERODETELEFONO")
Text22.Text = Text22.Text & RS("ENTREGADOPOR")
Text23.Text = Text23.Text & RS("RECIBIDOPOR")
Text24.Text = Text24.Text & RS("FECHA")
Text8.Text = Text8.Text & RS("EQUIPOEN")
RS.MoveNext
Loop
endif

basicamente muevo la tabla al primer registro para saber si tiene datos, si no encuentra ningun registro, el programa se cae con un error 3021, el if captura cualquier error ke genere el movefirst y envia el mensaje ke kieras.
  #3 (permalink)  
Antiguo 22/06/2007, 09:33
 
Fecha de Ingreso: abril-2007
Mensajes: 88
Antigüedad: 17 años
Puntos: 0
De acuerdo Re: """msgbox no hay datos"""

excelente funciona al pelo gracias espero sirva para otros
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:33.