Spis treści: (ukryj)
Dim conDatabase As ADODB.Connection Dim strSQL As String Set conDatabase = CurrentProject.Connection strSQL = "UPDATE tblCustomers SET Phone = 'None'" conDatabase.Execute strSQL MsgBox "All phones have been set to ""None""." conDatabase.Close Set conDatabase = Nothing
Dim conDatabase As ADODB.Connection
Dim rstCustomers As ADODB.Recordset
Dim strSQL As String
Set conDatabase = CurrentProject.Connection
strSQL = "SELECT Phone FROM tblCustomers"
Set rstCustomers = New Recordset
rstCustomers.Open strSQL, conDatabase, _
adOpenDynamic, adLockOptimistic
With rstCustomers
Do While Not .EOF
!Phone = "None"
'^^^^^-- nazwa pola z SELECTa
.Update
.MoveNext
Loop
End With
MsgBox "All phones have been set to ""None""."
rstCustomers.Close
conDatabase.Close
Set rstCustomers = Nothing
Set conDatabase = Nothing
Powyższe należy wrzucić do procedury lub funkcji, które deklaruje się odpowiednio:
' Procedura. Może być Private lub Public Private Sub nazwa_procedury(parametry) ... End Sub Private Function nazwa_funkcji(parametry) ... End Function