Hi y'all
Can I reference a cell in an access table within a VBA code?? I have 1 x 2 table (1 row and 2 columns). The first column is just an autoID generator. The second column keeps track of dates. I want to write a VB code that changes the table record in row 1, column 2 of the table, tblDate. The field name is ChngDate
Here's my code:
Can I reference a cell in an access table within a VBA code?? I have 1 x 2 table (1 row and 2 columns). The first column is just an autoID generator. The second column keeps track of dates. I want to write a VB code that changes the table record in row 1, column 2 of the table, tblDate. The field name is ChngDate
Here's my code:
Code:
Sub SetDate()
Dim CellDate As Date
' Assign data in cell (row 1, col 2) to CellDate
CellDate = DateValue(tblDate.ChngDate)
' Add 3 months to the CellDate
CellDate = DateAdd("m", 3, tblDate.ChngDate)
' Assign the new value back to the Table
tblDate.ChngDate = CellDate
' Begin loop when date in table cell (row 1, col 2) = current system date
Do While CellDate = Date
' Add 3 months to current date in table cell (row 1, col 2)
CellDate = DateAdd("m", 3, Date)
' Assign the new value back to the Table
tblDate.ChngDate = CellDate
Loop
End Sub
Comment