Edit Button on Continuous Form

Heythere82

Registered User.
Local time
Today, 04:19
Joined
Feb 17, 2016
Messages
14
I have an Edit button next to each record on my continuous form. I would like the edit button to open that specific record in a separate form so the record can be altered and updated.

I know the easiest option is to just make the controls editable on the continuous form...This inst an option because the continuous form is re-querying every second on a timer event (in order to populate a elapsed time for each record). If you click on anything on the form, focus immediately moves back to the current record at the top of the form the next second. (maybe there's a way to fix this?)

Is there any way to have a edit button that takes me to that specific record?

I must be overlooking something obvious because this seems like a issue that must happen a lot.:confused:
 
Thank You Paul!


I remember finding your website a few months ago. You're just amazing! :D

That second link is the key. Now whenever an edit button is pressed, the form will stay on that record and I can grab the ID for referencing.
 
Happy to help!!
 
Here is another approach for keeping the same place on a form. The first code goes in a standard code module and then you call it from your form's event.

Code:
Public Sub RequeryFormAndKeepCurrentlySelectedRecord(F As Form)
'http://stackoverflow.com/questions/2426371/in-an-access-form-how-to-return-to-previous-record-after-requery
'http://stackoverflow.com/questions/8787979/how-do-i-reference-the-current-form-in-an-expression-in-microsoft-access
'20160128
    Dim Position As Long
    Position = F.CurrentRecord
    F.Requery
    If F.Recordset.RecordCount > 1 And Position > 1 Then
        F.Recordset.Move Position - 1 'Zero based
    End If
End Sub
For example, this is called from the Click event.

Code:
Private Sub txtCOMPANY_Click()
...
Call RequeryFormAndKeepCurrentlySelectedRecord(Me)
...
End Sub
 
For clarity, I think that will return to the same position on the form, not necessarily the same record. In other words, if you were on the 10th record from the top, ID 123, it will return you to the 10th record. If records were added or deleted before the requery, the 10th record might not be ID 123 anymore.
 
Thanks for clarifying. As you pointed out, the code was set up so that when a record was added or deleted from the form, cursor would stay in the same position. So may not apply to what the OP was needing. Sorry if my contribution confuses the issue.
 
Either method could be appropriate in different situations, so better to have options.
 

Users who are viewing this thread

Back
Top Bottom