0
我有下面列自動填充訪問表和更新查詢
Id process
1 Lotus
2
3
4 Rose
5
6
7
8 Lilly
9
10
我要尋找一個更新查詢,它可以在Excel中fuctionality同一行filldown一個訪問表。
我有下面列自動填充訪問表和更新查詢
Id process
1 Lotus
2
3
4 Rose
5
6
7
8 Lilly
9
10
我要尋找一個更新查詢,它可以在Excel中fuctionality同一行filldown一個訪問表。
這將做你想做的。
Private Sub Command1_Click()
Dim Rs As Recordset, strSQL As String, CurData As Variant
'Note: Set a reference to the Microsoft DAO Object library via Tools | References
'Amend this to indicate the table and sort by the autonumber id
strSQL = "SELECT * FROM YOUR_TABLE"
'Opens a recordset (like a query) to the table
Set Rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
'Loop through the records in the table and if the previous row didnt have data in the
'Repaired_By field then populate the previous Repaired_By data. Assumes the first record is
'populated with info
Rs.MoveLast
Rs.MoveFirst
Do
If Rs!CONTACT_ID = "" Or IsNull(Rs!CONTACT_ID) Then
'This field is blank so populate the info from the variable
Rs.Edit
Rs!CONTACT_ID.Value = CurData
Rs.Update
Else
'This field isnt blank so store the info in the variable in case the next record is blank
CurData = Rs!CONTACT_ID.Value
End If
Rs.MoveNext
Loop While Not Rs.EOF
'Remove the recordset object from memory
Rs.Close
Set Rs = Nothing
End Sub