Trying to loop through the table "tbl247Stasging" and see if the field "EmployeeID is Null. If it is, I want to edit and update it with the current value of IDNUM, then increase the IDNUM value by 1 and continue looping until the end of the file.
Code Tags Added by UG
Please use Code Tags when posting VBA Code
Please feel free to Remove this Comment
https://www.access-programmers.co.u...e-use-code-tags-when-posting-vba-code.240420/
Code Tags Added by UG
Please use Code Tags when posting VBA Code
Please feel free to Remove this Comment
https://www.access-programmers.co.u...e-use-code-tags-when-posting-vba-code.240420/
Code:
Private Sub UpdateNullEmpID()
Dim db As DAO.Database
Set db = CurrentDb
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset("tbl247Staging")
Dim IDNum As Long
IDNum = 1
Dim i As Integer
For i = 0 To rs.RecordCount - 1
If rs.Fields.EmployeeID.Value = Null Then
rs.Edit
rs.Fields.EmployeeID.Value = IDNum
rs.Update
IDNum = IDNum + 1
Debug.Print rs.Fields.EmployeeID.Value
DoCmd.RefreshRecord
Else
End If
rs.MoveNext
Next i
rs.Close
Set rs = Nothing
End Sub
Last edited by a moderator: