
While not tabella.EOF tabella.Edit ... ... tabella.Update tabella.Movenext Wend |
Sub subst()
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("Tabella1")
While Not rs.EOF
If Left(rs!CampoA, 2) = "0X" Then
rs.Edit
rs!campoB = CurrentDb.OpenRecordset("SELECT CampoB FROM Tabella1 WHERE CampoA = '00" & Mid(rs!CampoA, 3) & "'")(0)
rs.Update
End If
rs.MoveNext
Wend
End Sub |
Sub subst()
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("Tabella1")
While Not rs.EOF
If Left(rs!CampoA, 2) = "0X" Then
rs.Edit
If CurrentDb.OpenRecordset("SELECT CampoB FROM Tabella1 WHERE CampoA = '00" & Mid(rs!CampoA, 3) & "'") is null then
rs!campoB = '0000'
Else
rs!campoB = CurrentDb.OpenRecordset("SELECT CampoB FROM Tabella1 WHERE CampoA = '00" & Mid(rs!CampoA, 3) & "'")(0)
End if
rs.Update
End If
rs.MoveNext
Wend
End Sub |
Sub subst()
Dim rs As DAO.Recordset, s as String
Set rs = CurrentDb.OpenRecordset("Tabella1")
While Not rs.EOF
If Left(rs!CampoA, 2) = "0X" Then
rs.Edit
s = "SELECT CampoB FROM Tabella1 WHERE CampoA = '00" & Mid(rs!CampoA, 3) & "'")
rs!campoB = Nz(CurrentDb.OpenRecordset(s)(0), "0000")
rs.Update
End If
rs.MoveNext
Wend
End Sub |
Option Explicit
Sub subst()
Dim rs As DAO.Recordset, rs2 As DAO.Recordset, s As String
Set rs = CurrentDb.OpenRecordset("Tabella1")
While Not rs.EOF
If Left(rs!CampoA, 2) = "0X" Then
rs.Edit
Set rs2 = CurrentDb.OpenRecordset("SELECT CampoB FROM Tabella1 WHERE CampoA = '00" & Mid(rs!CampoA, 3) & "'")
rs!campoB = IIf(rs2.RecordCount = 0, "0000", rs2!campoB)
rs.Update
End If
rs.MoveNext
Wend
End Sub
|
