I am using the code below to update the fields in a table. It works fine if I do one record at a time. What I want is to update all records when I click the button, I have tried so many things and none of them worked. What I am doing wrong?
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("Survey")
If IsNull(SpecimenDate) = False Then
Ageyrs = (SpecimenDate - Dob) / 365.5
Agemths = (SpecimenDate - Dob) / 30.46
Agewks = (SpecimenDate - Dob) / 7
Year = DatePart("yyyy", SpecimenDate)
Quarter = DatePart("q", SpecimenDate)
If Agemths < 2 Then
Agegp = "a. <2 months"
Agegp2 = "a. <3 months"
End If
rst.Close
Set rst = Nothing
JohnJoker
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("Survey")
If IsNull(SpecimenDate) = False Then
Ageyrs = (SpecimenDate - Dob) / 365.5
Agemths = (SpecimenDate - Dob) / 30.46
Agewks = (SpecimenDate - Dob) / 7
Year = DatePart("yyyy", SpecimenDate)
Quarter = DatePart("q", SpecimenDate)
If Agemths < 2 Then
Agegp = "a. <2 months"
Agegp2 = "a. <3 months"
End If
rst.Close
Set rst = Nothing
JohnJoker