How to Insert the Value that is in the same field in the Next Record

  • Thread starter Thread starter Irshad Alam
  • Start date Start date
I

Irshad Alam

We use or Press CTRL + APOSTROPHE (') to get the value of
the same field in the previous record
But what key should we press / what code should we write /
what Autokey we should make to Insert a value that is in
the same field in the next record.

Can any one suggest/advise me how to do.
We use or Press CTRL + APOSTROPHE (') to get the value of
the same field in the previous record
But what key should we press / what code should we write /
what Autokey we should make to Insert a value that is in
the same field in the next record.

Can any one suggest/advise me how to do.
 
Irshad Alam said:
We use or Press CTRL + APOSTROPHE (') to get the value of
the same field in the previous record
But what key should we press / what code should we write /
what Autokey we should make to Insert a value that is in
the same field in the next record.

Can any one suggest/advise me how to do.
We use or Press CTRL + APOSTROPHE (') to get the value of
the same field in the previous record
But what key should we press / what code should we write /
what Autokey we should make to Insert a value that is in
the same field in the next record.

Can any one suggest/advise me how to do.

I just put together the following *lightly tested* function to do it:

'----- start of code -----
Function CopyValueFromNextRecord()

Dim frm As Access.Form
Dim strCtlSource As String

On Error Resume Next
Set frm = Screen.ActiveForm
If Err.Number = 2475 Then
On Error GoTo Err_Handler
Set frm = Screen.ActiveDatasheet
End If
On Error GoTo Err_Handler

strCtlSource = frm.ActiveControl.ControlSource
If Len(strCtlSource) > 0 _
And Left(strCtlSource, 1) <> "=" _
Then
With frm.RecordsetClone
.Bookmark = frm.Bookmark
.MoveNext
If Not .EOF Then
frm.ActiveControl.Value = .Fields(strCtlSource).Value
End If
End With
End If

Exit_Point:
Set frm = Nothing
Exit Function

Err_Handler:
Resume Exit_Point

End Function
'----- end of code -----

It should work for the active form or datasheet. If you want to execute
it from an Autokeys macro, pick a key combination for the macro name and
use this for the macro:

Action: RunCode
Function: CopyValueFromNextRecord()

However, I have to warn you that I only tested this out as a sort of
"proof of concept". I didn't test the function thoroughly.
 
Back
Top