ayuda con MSHFlexGrid
Publicado por Halcon (9 intervenciones) el 28/02/2009 00:55:03
tengu un mshflexgrid en la cual tengo una columna de montos (iva) y los quiero sumar pero tambien quisiera ponerle formato de de moneda (0.00)
Tambien ene primer case is = 0 me lista cuando ingreso el denomico mi listra ne los dos Flex1 y Flex2 por el mismo nemonico;
pero cuando ingreso en el case is = 1 que cuando ingreso la obra no me lista y me emite un error que (no se han establecido valores para algunos parametros requeridos"
Private Sub TxtBusqueda_Change()
Dim i As Integer
Dim rs As New ADODB.Recordset
Dim rs3 As New ADODB.Recordset
Dim rsA As New ADODB.Recordset
Set rs3 = New ADODB.Recordset
Select Case TxtCol
Case Is = 0
With rs
.ActiveConnection = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & App.Path & "OBRAS.mdb"
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Open "Select * From OBRAS WHERE NEMONICO LIKE'" & TxtBusqueda & "%'"
With rsA
.ActiveConnection = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & App.Path & "OBRAS.mdb"
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Open "Select * From NEMONICO WHERE NEM LIKE'" & TxtBusqueda & "%'"
End With
End With
Case Is = 1
With rs
.ActiveConnection = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & App.Path & "OBRAS.mdb"
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Open "Select * From OBRAS WHERE OBRA LIKE'" & TxtBusqueda & "%'"
With rsA
.ActiveConnection = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & App.Path & "OBRAS.mdb"
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Open "Select * From NEMONICO WHERE NEMONICO LIKE'" & TxtBusqueda & "%'"
End With
End With
End Select
If rs.RecordCount = 0 Then
MsgBox "No hay coincidencias"
Exit Sub
End If
If rsA.RecordCount = 0 Then
MsgBox "No hay coincidencias"
Exit Sub
End If
With Flex1
.Cols = rs.Fields.Count
For i = 0 To .Cols - 1
.TextMatrix(0, i) = rs.Fields(i).Name
Next i
.Rows = rs.RecordCount + 1
.Row = 1
.Col = 0
.RowSel = .Rows - 1
.ColSel = .Cols - 1
.Clip = rs.GetString(, rs.RecordCount)
.Row = 1
End With
With Flex2
.Cols = rsA.Fields.Count
For i = 0 To .Cols - 1
.TextMatrix(0, i) = rsA.Fields(i).Name
Next i
.Rows = rsA.RecordCount + 1
.Row = 1
.Col = 0
.RowSel = .Rows - 1
.ColSel = .Cols - 1
.Clip = rsA.GetString(, rsA.RecordCount)
.Row = 1
End With
Label3.Caption = EnLetras(2500000.05)
End Sub
Function Autocompletar_MSHFlexGrid(MSHFlexGrid As Object, TBox As TextBox, columna As Long)
Dim i, j As Integer
Dim pos_SelStart As Integer
Set ConnPublic = New ADODB.Connection
Set rsPublic = New ADODB.Recordset
If (KeyRetroceso Or Len(TBox.Text) = 0) Then
KeyRetroceso = False
Exit Function
End If
With MSHFlexGrid
'Recorremos todas las filas del MshFlexgrid
For i = 0 To .Rows - 1
'Busca en el flexgrid si hay coincidencia, en la fila y columna actual
If InStr(1, .TextMatrix(i, columna), TBox.Text, vbTextCompare) = 1 Then
pos_SelStart = TBox.SelStart
'Asignamos el valor de la celda actual al textbox
TBox.Text = .TextMatrix(i, columna)
'Indicamos el comienzo de la selección
TBox.SelStart = pos_SelStart
'seleccionamos la porción de texto en el Text
TBox.SelLength = Len(.TextMatrix(i, columna)) - pos_SelStart
'Establecemos con TopRow , la fila arriba de todo
.TopRow = i
End If
Next i
End With
End Function
Tambien ene primer case is = 0 me lista cuando ingreso el denomico mi listra ne los dos Flex1 y Flex2 por el mismo nemonico;
pero cuando ingreso en el case is = 1 que cuando ingreso la obra no me lista y me emite un error que (no se han establecido valores para algunos parametros requeridos"
Private Sub TxtBusqueda_Change()
Dim i As Integer
Dim rs As New ADODB.Recordset
Dim rs3 As New ADODB.Recordset
Dim rsA As New ADODB.Recordset
Set rs3 = New ADODB.Recordset
Select Case TxtCol
Case Is = 0
With rs
.ActiveConnection = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & App.Path & "OBRAS.mdb"
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Open "Select * From OBRAS WHERE NEMONICO LIKE'" & TxtBusqueda & "%'"
With rsA
.ActiveConnection = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & App.Path & "OBRAS.mdb"
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Open "Select * From NEMONICO WHERE NEM LIKE'" & TxtBusqueda & "%'"
End With
End With
Case Is = 1
With rs
.ActiveConnection = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & App.Path & "OBRAS.mdb"
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Open "Select * From OBRAS WHERE OBRA LIKE'" & TxtBusqueda & "%'"
With rsA
.ActiveConnection = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & App.Path & "OBRAS.mdb"
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Open "Select * From NEMONICO WHERE NEMONICO LIKE'" & TxtBusqueda & "%'"
End With
End With
End Select
If rs.RecordCount = 0 Then
MsgBox "No hay coincidencias"
Exit Sub
End If
If rsA.RecordCount = 0 Then
MsgBox "No hay coincidencias"
Exit Sub
End If
With Flex1
.Cols = rs.Fields.Count
For i = 0 To .Cols - 1
.TextMatrix(0, i) = rs.Fields(i).Name
Next i
.Rows = rs.RecordCount + 1
.Row = 1
.Col = 0
.RowSel = .Rows - 1
.ColSel = .Cols - 1
.Clip = rs.GetString(, rs.RecordCount)
.Row = 1
End With
With Flex2
.Cols = rsA.Fields.Count
For i = 0 To .Cols - 1
.TextMatrix(0, i) = rsA.Fields(i).Name
Next i
.Rows = rsA.RecordCount + 1
.Row = 1
.Col = 0
.RowSel = .Rows - 1
.ColSel = .Cols - 1
.Clip = rsA.GetString(, rsA.RecordCount)
.Row = 1
End With
Label3.Caption = EnLetras(2500000.05)
End Sub
Function Autocompletar_MSHFlexGrid(MSHFlexGrid As Object, TBox As TextBox, columna As Long)
Dim i, j As Integer
Dim pos_SelStart As Integer
Set ConnPublic = New ADODB.Connection
Set rsPublic = New ADODB.Recordset
If (KeyRetroceso Or Len(TBox.Text) = 0) Then
KeyRetroceso = False
Exit Function
End If
With MSHFlexGrid
'Recorremos todas las filas del MshFlexgrid
For i = 0 To .Rows - 1
'Busca en el flexgrid si hay coincidencia, en la fila y columna actual
If InStr(1, .TextMatrix(i, columna), TBox.Text, vbTextCompare) = 1 Then
pos_SelStart = TBox.SelStart
'Asignamos el valor de la celda actual al textbox
TBox.Text = .TextMatrix(i, columna)
'Indicamos el comienzo de la selección
TBox.SelStart = pos_SelStart
'seleccionamos la porción de texto en el Text
TBox.SelLength = Len(.TextMatrix(i, columna)) - pos_SelStart
'Establecemos con TopRow , la fila arriba de todo
.TopRow = i
End If
Next i
End With
End Function
Valora esta pregunta


0