2017-05-08 2 views
0

에 액세스 테이블을 채우고 난 엑셀에서 fuctionality 같은 라인 filldown을 가질 수 있습니다 내가 업데이트 쿼리를 찾고 있어요 아래 열자동 업데이트 쿼리

Id process 

1 Lotus 

2 
3 
4 Rose 

5 
6 
7 
8 Lilly 

9 
10 

과 액세스 테이블이 있습니다.

답변

0

원하는대로 할 수 있습니다.

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