The Data set I am working on has only one field ("All Data"). I want to insert a new record that reads "Balance" just above an existing record that reads "Opening Balance"
I have the code for adding the record but when i run that it adds the record randomly rather than the the position that I want to set it up (ie above existing record that reads "Opening Balance").
This is the code that I have written but am unable to correctly set the position for the new recordset
I am totally new with vba and am unable to find out if it is possible to set the position at all.
Your help is appreciated.
Thanks
I have the code for adding the record but when i run that it adds the record randomly rather than the the position that I want to set it up (ie above existing record that reads "Opening Balance").
This is the code that I have written but am unable to correctly set the position for the new recordset
Code:
Dim RS2 As DAO.Recordset
Dim thisonedb As Database
Set thisonedb = CurrentDb
Set RS2 = thisonedb.OpenRecordset("Select * from Data")
If RS2.RecordCount > 0 Then
RS2.MoveFirst
Do Until RS2.EOF = True
If InStr(1, RS2("AllData"), "Opening Balance") Then
RS2.AddNew
RS2("AllData").value = "Balance"
RS2.Update
End If
RS2.MoveNext
Loop
End If
I am totally new with vba and am unable to find out if it is possible to set the position at all.
Your help is appreciated.
Thanks