• Domingo 19 de Mayo de 2024, 08:41

Autor Tema:  Ayuda Por Favor, Es Urgenteeeeeee!!!  (Leído 1904 veces)

EduardoCab

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Ayuda Por Favor, Es Urgenteeeeeee!!!
« en: Martes 19 de Abril de 2005, 16:53 »
0
HOLA FORISTAS, NECESITO URGENTEMENTE DE SU AYUDA.
Estoy desarrollando un sistema de control de libros, he creado 3 optionbutton para seleccionar el tipo de busqueda, pero cuando quiero agregar un cuarto optionbutton me da error y se me cuelga la PC.
El código se los coloco a continuación:

He creado una DB en access que trabaja de esta manera:
Posee los campos:
- Codigo
- Nombre (que es el nombre del libro)
- Stock
- Prestados
Se desarrollo de la siguiente manera:
La introducción de datos se hace desde otro form (ahí no hay problema)
empece a crear un módulo .bas para las conexiones y todo.
Detalles del form de busqueda:
Se tiene 4 optionbutton para seleccionar por que campo quiero la busqueda:
optionbutton1 = Codigo
optionbutton2 = Nombre
optionbutton3 = Stock
Hasta aqui estoy bien y e funciona de maravilla, el problema es cuando quiero colocarle un cuarto optionbutton, me da el "error numero -2147217908 y me dice: No se establecio ningún texto para el objeto de comando" , te anexo acá el código que eh colocado:

Código del Form

Option Explicit
Dim I As Integer
Dim strSearchString As String
Dim strSearch As String
Dim CodigoFlag As Boolean
Dim NombreFlag As Boolean
Dim StockFlag As Boolean
-----------------------------------------------
Private Sub cmdSearch_Click()
On Error GoTo ErrorHandler
Screen.MousePointer = vbHourglass
Animation1.Visible = True
Animation1.AutoPlay = True
Animation1.Open App.Path & "/search.avi"
Animation1.Play (10)
Sleep (5000)

strSearchString = Trim(txtSearch.Text)
rstObj.Close
Set rstObj = Nothing
If CodigoFlag = True Then
strSearch = "SELECT * FROM Bibliotecario where Codigo Like '" & strSearchString & "%' Order By Codigo"
NombreFlag = False
StockFlag = False
End If
If NombreFlag = True Then
strSearch = "SELECT * FROM Bibliotecario where Nombre Like '" & strSearchString & "%' Order By Nombre"
CodigoFlag = False
StockFlag = False
End If
If StockFlag = True Then
strSearch = "SELECT * FROM Bibliotecario where Apellido Like '" & strSearchString & "%' Order By Stock"
CodigoFlag = False
NombreFlag = False
End If

Call OpenAccessRecordSet(strSearch)
MSFlexGrid1.Refresh
Call FillMSFlexGridWithData


Animation1.Visible = False
Screen.MousePointer = vbDefault
Exit Sub ' Exit to avoid handler.
ErrorHandler: ' Error-handling routine.
MsgBox "Error Number :" & Err.Number & vbCr & "Error Description :" & Err.Description
Animation1.Visible = False
Screen.MousePointer = vbDefault
Resume ' Resume execution at same line
' that caused the error.
cnxnObj.Close
Set cnxnObj = Nothing
End Sub
-------------------------------------------------
Private Sub cmdStop_Click()
Unload Me
Animation1.Visible = False
Screen.MousePointer = vbDefault
End
End Sub
-------------------------------------------------
Private Sub Form_Load()
frmSearch.Caption = Cap1
frmSearch.WindowState = 0
lblSearch.Caption = Cap2
cmdSearch.Caption = Cap3
cmdStop.Caption = Cap4
lblMsFlexGrid.Caption = Cap6
Animation1.Visible = False
optCodigo.Caption = Cap8
optNombre.Caption = Cap9
optStock.Caption = Cap10
optCodigo.Value = True
'// Open DataBase
Call OpenAccessDataBase
Call OpenAccessRecordSet("SELECT * FROM Bibliotecario Order By Codigo")
Call FillMSFlexGridWithData
End Sub
-------------------------------------------------------
Sub FillMSFlexGridWithData()
MSFlexGrid1.Cols = 4
MSFlexGrid1.ColWidth(0) = 1500
MSFlexGrid1.TextMatrix(0, 0) = "#"
For I = 0 To rstObj.Fields.Count - 1
MSFlexGrid1.ColAlignment(I) = vbCenter
MSFlexGrid1.ColWidth(I + 1) = 1500
MSFlexGrid1.TextMatrix(0, I + 1) = rstObj.Fields(I).Codigo
Next
MSFlexGrid1.Rows = rstObj.recordcount + 1
I = 1
Do While Not rstObj.EOF
MSFlexGrid1.TextMatrix(I, 0) = I
MSFlexGrid1.TextMatrix(I, 1) = rstObj("Codigo")
MSFlexGrid1.TextMatrix(I, 2) = rstObj("Nombre")
MSFlexGrid1.TextMatrix(I, 3) = rstObj("Stock")
I = I + 1
rstObj.MoveNext
Loop
End Sub
-------------------------------------------------------
Private Sub Form_Unload(Cancel As Integer)
Set cnxnObj = Nothing
Set rstObj = Nothing
End Sub
-------------------------------------------------------
Private Sub optStock_Click()
CodigoFlag = False
NombreFlag = False
StockFlag = True
End Sub
-------------------------------------------------------
Private Sub optNombre_Click()
CodigoFlag = False
NombreFlag = True
StockFlag = False
End Sub
------------------------------------------------------
Private Sub optCodigo_Click()
CodigoFlag = True
NombreFlag = False
StockFlag = False
End Sub
------------------------------------------------------
Private Sub txtSearch_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdSearch_Click
End If
End Sub


Código del Módulo.bas

Option Explicit

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Const Cap1 = "Busqueda de Libros en Stock y prestados"
Public Const Cap2 = "Escriba el Dato de Busqueda >>"
Public Const Cap3 = "Buscar"
Public Const Cap4 = "Stop"
Public Const Cap5 = "Listado de Libros"
Public Const Cap6 = "Listado General de Libros"
Public Const Cap7 = "Listado General"
Public Const Cap8 = "Buscar por Código"
Public Const Cap9 = "Buscar por Nombre"
Public Const Cap10 = "Buscar por Stock"
Public cnxnObj As Object
Public rstObj As Object
-------------------------------------------------------
Sub main()
Load frmSearch
frmSearch.Show
End Sub
------------------------------------------------------
Public Sub OpenAccessDataBase()
Dim AccessConnect As String
Dim strFileName As String
Dim strFilePath As String

strFileName = "Bibliotecario.mdb"
strFilePath = App.Path
Set cnxnObj = CreateObject("ADODB.Connection")
AccessConnect = "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=" & strFileName & ";" & _
"DefaultDir=" & strFilePath & ";" & _
"Uid=Admin;Pwd=;"
cnxnObj.Open AccessConnect

End Sub
-----------------------------------------------------------------
Public Sub OpenAccessRecordSet(strSQL As String)
Set rstObj = CreateObject("ADODB.Recordset")
rstObj.Open strSQL, cnxnObj, 1, 1, 1
End Sub


Ok, hasta acá todo bien, me funciona de maravilla.
El problema es cuando quiero agregarle la opcion de "prestamos, lo que hago es lo siguiente:

En el Form:
Dim PrestadosFlag As Boolean
---------------------------------------------
If PrestadosFlag = True Then
strSearch = "SELECT * FROM Bibliotecario where Prestados Like '" & strSearchString & "%' Order By Prestados"
CodigoFlag = False
NombreFlag = False
StockFlag = False
PrestadosFlag = True
End If
---------------------------------------------------------
En el evento Private Sub Form_Load() le agrego:
optprestados.Caption = Cap11
------------------------------------------------
En el evento Sub FillMSFlexGridWithData() le agrego:
MSFlexGrid1.Cols = 5 (aca le sumo uno mas por el prestados)
MSFlexGrid1.TextMatrix(I, 4) = rstObj("Prestados")
--------------------------------------------------------
Le agrego el Private Sub optPrestados_Click()
CodigoFlag = False
NombreFlag = False
StockFlag = False
PrestadosFlag = True
End Sub

En el Módulo.bas

Public Const Cap11 = "Prestados"

Eso es lo que agrego en el form y en el módulo
Cuando corro el programa me lo abre y todo pero al querer buscar por Prestados, me corre el .AVI, pero al momento me sale el siguiente error:
Error Number: -2147217908
No se estableció ningún texto para el objeto de comando
Se me cuelga la PC y al querer finalizar la tarea del sistema con el Administrador de Tareas de Windows se me cierra Basic.

Si me podes ayudar con esto se los agradeceré muchísimo.
Saludos

juravi

  • Miembro activo
  • **
  • Mensajes: 94
    • Ver Perfil
    • http://spaces.msn.com/members/ingjuan
Re: Ayuda Por Favor, Es Urgenteeeeeee!!!
« Respuesta #1 en: Jueves 21 de Abril de 2005, 05:15 »
0
Hola...  :devil:
Dejame ver si te  entendi :comp:
tienes 4 opciones, la ultima es prestados que es la que te manda error,
ese option4 me imagino que debe estar en el formulario al igual q los otros 3.. .
Mira hagamos algo..... Usa el F8 para q lo ejecutes paso a paso el software.. y verifica donde es que se cae... si no das con el problema copiame una imagen de donde sale el error... si usas manejador de error... deshabilitalo un rato para q no se valla al mensaje...
por q en realidad no le veo el error... es mas facil encontrarlo en corrida.
Has lo q te digo y me havisas....
Mi correo de msn de hotmail es mksjrmileniun@yahoo.com.mx por si quieres ayuda directa..... me conecto en las mañanas hora panameña.
saludos :kicking:
El Fin justifica los Medios
 _______________________
ﻞυגανι.Corp [The Designer]
<a href=\'mailto]No sé el secreto para llegar al éxito, pero sé que tratar de agradar a todos es lo que te llevará al fracaso... Piénsalo!!![/color]