Aprire il database di Access Northwind di Microsoft Office . Il database Northwind è incluso nella suite Microsoft Office . Selezionare il menu "Inserisci" e fare clic su 
 2 
 digitare quanto segue per dichiarare le variabili "Modulo ". : 
 
 Dim rst come Recordset 
 
 Dim dbs As Database 
 
 Dim queryStr As String Dim 
 
 qryPrev As String Dim 
 
 qryCurrent As String Dim 
 
 rstCnt As Integer 
 
 Set dbs = CurrentDb 
 3 
 digitare quanto segue per interrogare la tabella " Fornitori " : 
 
 queryStr = "SELECT Suppliers.Company , " 
 
 queryStr = queryStr & " fornitori [ Cognome ] , " 
 
 queryStr = queryStr & " fornitori [ Nome ] " 
 
 queryStr = queryStr & " dai fornitori; . ». 
 4 
 Digitare il comando seguente per aprire un nuovo Recordset : 
 
Set rst = dbs.OpenRecordset ( queryStr ) per
 rst.MoveLast 
 
 rst.MoveFirst 
 5 
 Digitare quanto segue per scorrere i record del Recordset e confrontare il record corrente con il record precedente : 
 
 rstCnt = 0 per rst.RecordCount - 1 
 
 qryPrev = RST . Fields ( "Società") . Valore 
 
 qryPrev = qryPrev & rst.Fields ( " [ Nome ]") . Valore 
 
 qryPrev = qryPrev & rst.Fields ( " [ Nome ] « . ) Valore 
 
 rstCnt < > rst.RecordCount - 1 Poi 
 
 rst.MoveNext 
 
qryCurrent = rst.Fields ( " . Società " ) Valore < br
 qryCurrent > = qryCurrent & rst.Fields ( " [ Nome ]") . Valore 
 
 qryCurrent = qryCurrent & rst.Fields ( " [ Nome ]") . Valore 
 
 Se qryPrev = qryCurrent Poi 
 
 Debug.Print " Record precedente è identico al record corrente . " 
 
 Debug.Print qryPrev 
 
 Debug.Print qryCurrent 
 
 End If 
 
 Else 
 
 Debug.Print " Finished confrontando tutti i record ". 
 
 End If 
 
 Avanti rstCnt 
 6 
 Digitare quanto segue per cancellare le variabili dalla memoria : . 
 
 rst.Close 
 
 dbs.Close 
 
 Premere " F5 " per eseguire la subroutine 
 
              
Programmazione © www.354353.com