Google
 

it » comp » appl » access

Individuare i record selezionati in una Sottomaschera

di "Marco Papo"
il Wed, 11 Jul 2007 14:49:31 +0200
newsgroups it.comp.appl.access
message-id <f72jkt$c8s$1@aioe.org>

Ciao,

Ho uma maschera con sottomaschera continua. Quando evidenzio i records per 
cancellarli voglio chiedere prima una conferma. Per fare questo ho scritto 
il seguente codice...

    Dim F As Form
    Dim strSQL As String

    Set F = Forms("MAS_Inventario_Pallet").MAS_Inventario_Codice.Form
    ' Chiamo la funzione che mi ritorna la stringa SQL che contiene le 
chiavi dei records da eliminare.
    strSQL = SelectedRecordsSQLStringKey(F, "IDVoce")


Il mio problema è nella seguente funzione, alla riga evidenziata con 
asterischi

Public Function SelectedRecordsSQLStringKey(F As Form, ID As String) As 
String

    Dim i As Long
    'Dim F As Form
    Dim RS As Recordset

    Dim strSQL As String
    Dim firstCondition As Boolean

    firstCondition = True

    ' Get the form and its recordset.
    Set RS = F.RecordsetClone

    ' Move to the first record in the recordset.
    RS.MoveFirst

    ' Move to the first selected record.
    RS.Move F.SelTop - 1

    ' Enumerate the list of selected records presenting
********************************
' Non mi cicla perchè il SelHeight è 0.
    For i = 1 To F.SelHeight
        If firstCondition = True Then
            strSQL = ID & " = " & RS.Fields(ID)
            firstCondition = False
        Else
            strSQL = strSQL & " OR " & ID & " = " & RS.Fields(ID)
        End If
    RS.MoveNext
    Next i

    SelectedRecordsSQLStringKey = strSQL

End Function


Se eseguivo il seguente codice dall'evento OnDelete della sottomaschera 
funzionava. Perchè se l'eseguo da un bottone sulla maschera principale non 
va?

Grazie



Risposte

Tutti i messaggi della discussione