| 
 | |||||||
| 
 | 
|  | 
|  | 
|  | Strumenti | 
|  20-07-2009, 09:30 | #1 | 
| Member Iscritto dal: May 2004 Città: Modena 
					Messaggi: 46
				 | 
				
				[VBA - ACCESS 2007] La ricerca non funziona più!
			 
		Ciao a tutti, spero di aver postato nella sezione giusta: Ho un db in access 2003 con una funzione di ricerca trovata in internet e che avevo adattato alle mie esigenze, ma, convertendo il db in access 2007 non funziona più! L'errore che mi da quando arriva al punto indicato sotto è "Record non corrispondente" La funzione cerca viene richiamata al click di un pulsante in questo modo Codice: Dim fun as new clsUtility
Private Sub attivaRicerca_Click() 'OK
    Call fun.cerca(Me, Forms!Atleti)
End Subil codice della funzione di ricerca è questo Codice: Private rst As Recordset
Private nomeCampo As Field
Private strValoreCampo, strCampoSingolo As String
Private contaTrovate As Integer
Private trovatoQualcosa, trovataParola, chkParolaEsatta As Boolean
Function cerca(meValue As Object, maschera As Form)
Set rst = maschera.RecordsetClone    ==> SI BLOCCA QUI
strValoreCampo = ""
strCampoSingolo = ""
trovatoQualcosa = False
trovataParola = False
chkParolaEsatta = True
    
If Not meValue!chkGiaTrovata Then
    rst.MoveFirst
    contaTrovate = 0
Else
    rst.Bookmark = meValue.Bookmark
    rst.MoveNext
End If
If meValue!campoSingolo = True Then
    strCampoSingolo = meValue!elencoCampoSingolo.Value
End If
Do While Not rst.EOF
    For Each nomeCampo In rst.Fields
        If meValue!campoSingolo Then
            If nomeCampo.Name = strCampoSingolo Then 'Or rst.EOF Then
                res = subCerca(meValue, maschera)
                If res = selectOption.OK Then Exit Do
                Exit For
            End If
        Else
            res = subCerca(meValue, maschera)
            If res = selectOption.OK Then Exit Do
        End If
    Next
    rst.MoveNext
Loop
    
If contaTrovate = 0 Then
    msgReturn = MsgBox("Elemento non trovato", vbInformation + vbOKOnly, 
"Nessun risultato")
ElseIf rst.EOF Then
    msgReturn = MsgBox("Ricerca Terminata!" & vbCrLf & _
                        "Per ripartire dal primo record" & vbCrLf & _
                            "fare click sul tasto di ricerca", vbInformation 
+ vbOKOnly, "Fine")
End If
Set rst = Nothing
Set nomeCampo = Nothing
End Function
Private Function subCerca(meValue As Object, maschera As Form) As Integer
Dim strCampoRicerca As String
If Not nomeCampo.Name = "Foto" And Not nomeCampo.Name = "Percorso Cert. PDF" 
And Not rst.EOF Then
    strValoreCampo = Nz(rst(nomeCampo.Name), "")
    strCampoRicerca = Nz(meValue!Ricerca, "")
    
    If meValue!parolaIntera Then
        If InStr(1, strValoreCampo, meValue!Ricerca & IIf(chkParolaEsatta, " 
", "")) = Nz(strValoreCampo, "") Or strValoreCampo = strCampoRicerca Then
            trovatoQualcosa = True
            trovataParola = True
        End If
    Else
        If Not trovataParola Then
            If InStr(1, strValoreCampo, meValue!Ricerca) > 0 Then
                trovatoQualcosa = True
                trovataParola = True
            End If
        End If
    End If
                    
    If trovataParola Then
        meValue!chkGiaTrovata = True
        contaTrovate = contaTrovate + 1
        meValue.Bookmark = rst.Bookmark
            
        If meValue(nomeCampo.Name).Enabled = True Then
            meValue("[" & nomeCampo.Name & "]").SetFocus
            meValue(nomeCampo.Name).SelStart = InStr(1, meValue!Ricerca, 
Nz(meValue(nomeCampo.Name).Value, ""))
            meValue(nomeCampo.Name).SelLength = Len(meValue!Ricerca)
        End If
        subCerca = selectOption.OK
        Exit Function
    Else
        meValue!chkGiaTrovata = False
    End If
End If
End Functionguardando la documentazione non mi sembra. 
				__________________    Volly86     | 
|   |   | 
|  23-07-2009, 13:54 | #2 | 
| Senior Member Iscritto dal: Dec 2004 
					Messaggi: 3210
				 | 
		Purtroppo temo si tratti di un bug di Access 2007, peraltro non ancora ufficialmente risolto.  Se vai qui : http://allenbrowne.com/Access2007.html a mezza pagina c'è una lista ( What's broken (new bugs) ), abbastanza lunghetta, dei nuovi bugs di Access 2007... Uno dei tanti motivi per cui io rimango ancora fedele al mio Office 2003...   Troverai anche il tuo RecordsetClone, purtroppo non ancora fixato dopo il SP2. Qui, invece, una possibile tecnica di workaround che dovrai adattare al tuo caso : http://allenbrowne.com/RecordCountError.html Prova...   | 
|   |   | 
|   | 
| Strumenti | |
| 
 | 
 | 
Tutti gli orari sono GMT +1. Ora sono le: 20:24.









 
		 
		 
		 
		






 
  
 



 
                        
                        










