Hi,
I have two tables in a database in Access, the first one is a table with a week column and a date column. The second one has a colum called dates and if that date matches the date on the first table the week column has to be updated with the corresponding week from the first table.
I tried some VBA code but is not working:
Sub Calendar()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tbl_Mail", dbOpenDynaset) 'Open table tblMail
Set rst1 = db.OpenRecordset("Calendar", dbOpenDynaset) 'Open Calendar table
If (rst1!Dates = rst!Date) Then
rst.AddNew
rst!Week = rst1!Week
rst2.Update
End If
Set rst = Nothing
Set rst1 = Nothing
Set rst2 = Nothing
Set db = Nothing
End Sub
I have two tables in a database in Access, the first one is a table with a week column and a date column. The second one has a colum called dates and if that date matches the date on the first table the week column has to be updated with the corresponding week from the first table.
I tried some VBA code but is not working:
Sub Calendar()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tbl_Mail", dbOpenDynaset) 'Open table tblMail
Set rst1 = db.OpenRecordset("Calendar", dbOpenDynaset) 'Open Calendar table
If (rst1!Dates = rst!Date) Then
rst.AddNew
rst!Week = rst1!Week
rst2.Update
End If
Set rst = Nothing
Set rst1 = Nothing
Set rst2 = Nothing
Set db = Nothing
End Sub