Hi Spyder1000,
I had a similar problem where I needed to "copy down" a value to blank cell under it, to complete the record. Below is the code that a friend of mine assisted me with to solve this problem. I then built a macro to run this module. Works great.
Option Explicit
Option Compare Database
Function Missing_Data_New()
' Declare Local Variables
Dim strSavMyField As String ' Saved MYFIELD from previous record
Dim myConnection As ADODB.Connection ' ADO Database connection
Dim myRecordset As ADODB.Recordset ' ADO Updatable Recordset
' Handle any errors
On Error GoTo Proc_Err
' Instantiate a connection and recordset of declared type
Set myConnection = New ADODB.Connection
Set myRecordset = New ADODB.Recordset
With myConnection
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source=C:\MYDATABASE.mdb"
.Mode = adModeReadWrite
.Open
End With
myRecordset.ActiveConnection = myConnection
myRecordset.Open "MYTABLE", , adOpenDynamic, adLockOptimistic
myRecordset.MoveFirst
With myRecordset
Do While Not myRecordset.EOF
.Find "MYFIELD =" & "Null"
'If Not myRecordset.EOF Then
myRecordset.MovePrevious
strSavPatNo = myRecordset("MYFIELD")
myRecordset.MoveNext
myRecordset("MYFIELD") = strSavPatNo
'End If
myRecordset.MoveNext
Loop
End With
myRecordset.Close
Set myRecordset = Nothing
Set myConnection = Nothing
Proc_Exit:
Exit Function
Proc_Err:
MsgBox Err.Description, vbCritical
Resume Proc_Exit
End Function