questo è il modulo.codice:Option Compare Database Option Explicit Public Function leggicolonna() As Variant Dim dbs, cbs As Database Dim rst, cst As Recordset Dim strSQL As String Dim indir As String Dim citt As String Dim nome As String Dim usci As Recordset Dim po As Integer ' Restituisce il riferimento al database corrente. Set dbs = CurrentDb Set usci = CurrentDb().OpenRecordset("uscita") ' imposta la SQL di selezione strSQL = "SELECT * FROM sasReport" Set rst = dbs.OpenRecordset(strSQL) rst.MoveFirst While Not rst.EOF nome = rst("nome") po = InStr(1, nome, ",") If po <> 0 Then nome = Mid(nome, 1, po - 1) End If If Splitta(rst("indirizzo"), indir, citt) = True Then If nome <> "" Or indir <> "" Or citt <> "" Then usci.AddNew usci.Fields(0) = nome usci.Fields(1) = indir usci.Fields(2) = citt usci.Update End If End If rst.MoveNext Wend rst.Close usci.Close Set usci = Nothing Set dbs = Nothing End Function Function Splitta(strProblemAddress, indirizzo, citta As String) As Boolean 'Remember your error handling Dim strResults, stringa As String Dim iCounter As Integer Dim iStartHere, SH, appoggio As Integer iStartHere = 1 SH = iStartHere Do While Not SH = Len(strProblemAddress) stringa = Mid$(strProblemAddress, SH, 5) If (IsNumeric(stringa) And Left(stringa, 1) <> " ") Then Exit Do Else SH = SH + 1 End If Loop indirizzo = Left(strProblemAddress, SH - 1) citta = Right(strProblemAddress, Len(strProblemAddress) - SH + 1) Splitta = True End Function
in ingresso viene valorizzata una tabella a 2 colonne : nome e indirizzo.
in uscita viene valorizzata una tabella a 3 colonne: nome, via e civico, cap
BUONE FESTE!!![]()



Rispondi quotando