1.
I don't know the name of the Number field in your Table that has the Year.
In my example below I have called that field YearField.
You can put in the correct name of your field wherever you see 'YearField'.
If you have spaces in your field name -
Eg: Year Field
then put the field name into box brackets - like this: [Year Field].
In my example that would look like this:
[mtb-STAT3AR1].[Year Field]
2.
In my code - you will notice 'Me.StrYear'. The StrYear is the name of the TextBox on my Form that has the YYYY year that will be put into the Year field in the Table.
Replace StrYear with the name of the text box on YOUR Form that has the Year that you want to put into your Table.
You will need a Command Button on your Form.
In my example below - I've called the Command Button cmdUpdate.
Right-Click the Command Button -> Build Event -> Code Builder.
If your command button is named cmdUpdate, you will see a window open with this in it:
Code:
Private Sub cmdUpdate_Click()
End Sub
Now - paste this code:
Code:
Dim db As Database
Set db = CurrentDb
db.Execute ("UPDATE mtb-STAT3AR1 SET mtb-STAT3AR1.YearField = " & Me.StrYear & " WHERE mtb-STAT3AR1.YearField Is Null")
into that Sub [Sub Routine] - between those two lines above.
It should end up looking like this:
Code:
Private Sub cmdUpdate_Click()
Dim db As Database
Set db = CurrentDb
db.Execute ("UPDATE mtb-STAT3AR1 SET mtb-STAT3AR1.YearField = " & Me.StrDate & " WHERE mtb-STAT3AR1.YearField Is Null")
End Sub
Now - as long as you have replaced my 'YearField' with the name of the Year field in your Table - that code should put the Year from the text Box on your Form into all the Year fields in your table that are Null.
I hope this helps!