Home > Net >  how to fill down when empty cells in access db
how to fill down when empty cells in access db

Time:12-21

db access table

kindly i need help to fill down with previous string PS: i am a beginner

CodePudding user response:

Your Date field seems to be of data type Text. If so, change that to DateTime.

Then you can run a loop to update the records having no date value:

Dim Records     As DAO.Recordset

Dim Sql         As String
Dim LastDate    As Date

Sql = "Select * From YourTable Order By [Surevey ID]"
Set Records = CurrentDb.OpenRecordset(Sql)

If Records.RecordCount > 0 Then
    LastDate = Date ' Adjust if needed.
    Records.MoveFirst
    While Not Records.EOF
        If IsNull(Records!Date.Value) Then
            Records.Edit
                Records!Date.Value = LastDate
            Records.Update
        Else
            LastDate = Records!Date.Value
        End If
        Records.MoveNext
    Wend
End If
Records.Close
  • Related