hice los siguientes cambios:
a la tabla, solo hice la columna ID Primary Key. Tambien cambie el ID para que sean unicos, si no, no se puede crear el Primary Key.
a el formulario:
1) cambie el SQL the la lista de contenido para que incluya el titulo y ID.
luego, enlaze el evento CHANGED de el List Box lbJumpTo (la que quieres usar para buscar) al macro lbJumpTo_OnChanged. lye hice unos cambios ha este macro para que funcione con los datos de ty tabla. el ejemplo que te habia mandado usaba un INTERGER, pero la columna ID es un STRING/VARCHAR.
los macros que use son estos:
Código: Seleccionar todo
Sub lbJumpTo_OnChanged(Event As Object)
Dim SelValue As String
Dim SelIndex As Integer
Dim ListBox As Object
Dim Form As Object
Dim Pos As Integer
ListBox=Event.Source.Model
Form=ListBox.Parent
SelIndex=ListBox.SelectedItems(0)
If SelIndex=0 Then Exit Sub
SelValue=ListBox.ValueItemList(SelIndex)
'MsgBox SelIndex
'MsgBox Join(ListBox.ValueItemList,",") & chr(10) & SelIndex & ": " & SelValue
Form.CancelRowUpdates() 'else the value will be changed
Pos=findFirst(Form,"ID",SelValue)
If Pos>0 Then Form.absolute(Pos)
End Sub
Function findFirst(Form As Object, ColumnName As String, Target As Variant,Optional StartPos As Integer) As Integer
REM FIND THE FIRST OCCURRENCE OF TARGET
Dim rs as Object
Dim ColIndex As Integer
Dim Column As Object
Dim FirstPos As Integer
Dim ColumnValue As Variant
Dim FormImpName As String
FormImpName="com.sun.star.comp.forms.ODatabaseForm"
REM ONLY WORK WITH FORM FOR THE MOMMENT
REM COULD HVE IT WORK FOR RESULTSET AND ROWSET AS WELL
If Form.ImplementationName<>FormImpName Then
Exit Function
End If
If IsMissing(StartPos) Then
StartPos=1
End If
rs=Form.createResultSet()
ColIndex=rs.findColumn(ColumnName)
If ColIndex<1 Or ColIndex > rs.Columns.Count Then
Exit Function
End If
rs.absolute(StartPos)
REM IF NOT BOTTOM GUARDED LOOP, FIRST ITERATION WILL BE SKIPPED
REM THIS IS NOT GOOD AS THIS COULD BE THE FIRST OCCURRENCE
Do
Column=rs.Columns.getByName(ColumnName)
ColumnValue=getXXX(Column)
If ColumnValue=Target Then
findFirst=rs.Row
Exit Function
End If
Loop While rs.next()
End Function
Function getXXX(col) As Variant
REM col is a column object.
REM SELECT CASE gets property that corresponds to datatype passed
Dim ret
Select Case col.TypeName
Case "ARRAY": ret=col.Array
Case "BLOB": ret=col.Blob
Case "BOOLEAN": ret=col.Boolean
Case "BYTE": ret=col.Byte
Case "BYTES": ret=col.Bytes
Case "BLOB": ret=col.Clob
Case "DATE": ret=col.Date
Case "DOUBLE": ret=col.Double
Case "INTEGER": ret=col.Int
Case "LONG": ret=col.Long
Case "DECIMAL": ret=col.Double
Case "NULL": ret=col.Null
Case "OBJECT": ret=col.Object
Case "REF": ret=col.Ref
Case "SHORT": ret=col.Short
Case "VARCHAR": ret=col.String
Case "TIME": ret=col.Time
Case "TIMESTAMP": ret=col.TimeStamp
Case Else: ret=col.String 'GIVE STRING A TRY
End Select
getXXX=ret
End Function
creo que se me abia olvidado incluir el ultimo (getXXX)
estos macros los salve en la Biblioteca STANDARD de el formulario, en el Modulo [Peliculas]
-->no se si lo has visto, pero en este hilo [
http://user.services.openoffice.org/es/ ... f=50&t=229] hay un tutorial que demuestra como programar con OOo y Basic--este esta en espanol. yo tengo unos documentos en
http://www.geocities.com/rbenitez22 pero estan en ingles.