Ciao a tutti ho trovato e riadattato il codice che si trova a questo link http://allenbrowne.com/ser-32.html che e' diventato questo:
codice:
Option Compare Database
Option Explicit
Dim sSuburbStub As String
Const conSuburbMin = 4
Function ReloadSuburb(sSuburb As String)
Dim sNewStub As String ' First chars of Suburb.Text
sNewStub = Nz(Left(sSuburb, conSuburbMin), "")
' If first n chars are the same as previously, do nothing.
If sNewStub <> sSuburbStub Then
If Len(sNewStub) < conSuburbMin Then
'Remove the RowSource
Me.clienti.RowSource = "SELECT id,nome FROM spunta WHERE (False);"
sSuburbStub = ""
Else
'New RowSource
Me.clienti.RowSource = "SELECT id,nome FROM spunta WHERE (nome Like '*" & _
sNewStub & "*') ORDER BY nome;"
Me.clienti.Requery
Me.clienti.Dropdown
sSuburbStub = sNewStub
End If
End If
End Function
Private Sub clienti_AfterUpdate()
Dim cbo As ComboBox
Set cbo = Me.clienti
If Not IsNull(cbo.Value) Then
End If
Set cbo = Nothing
End Sub
Private Sub clienti_Change()
Dim cbo As ComboBox ' Suburb combo.
Dim sText As String ' Text property of combo.
Set cbo = Me.clienti
sText = cbo.Text
Select Case sText
Case " " ' Remove initial space
cbo = Null
Case "MT " ' Change "Mt " to "Mount ".
cbo = "MOUNT "
cbo.SelStart = 6
Call ReloadSuburb(sText)
Case Else ' Reload RowSource data.
Call ReloadSuburb(sText)
End Select
Set cbo = Nothing
End Sub
Private Sub Form_Current()
Call ReloadSuburb(Nz(Me.clienti, ""))
End Sub
Private Sub Form_Load()
clienti.ColumnCount = 2
clienti.BoundColumn = 2
clienti.ColumnWidths = "0cm"
End Sub
clienti e' una combobox di una maschera access 2010 e vorrei che quando digito le lettere mi filtri l'elenco che viene caricato, ma in questo caso non filtra i dati ma li seleziona soltanto. Inotlre mi da errore alla riga me.clienti.requery nella funzione, l'errore e' questo: errore di runtime 2118 e' necessario salvare il campo corrente prima di eseguire l'azione RieseguiQuery. Mi potete dare una mano