Return on a specific record - Access Form

Posted on 2011-09-30
Last Modified: 2012-06-22

On a main form, I have a list of records, with a details button on each row.

When I click on the details button, a new form is opened with details of the selected record

When I close the details form, I would like to go back on the record previously selected.

Currently, I return on  the top of the records list in the main form.
Question by:Karl001
  • 2
  • 2
  • 2
LVL 119

Expert Comment

by:Rey Obrero
ID: 36891679
that is a normal behavior when you Requery the Form, the pointer goes to the first record..

'save the recordid in a variable

dim varID
varID = me.recordId

'after the requery, find the record using

me.recordsetclone.findfirst "[recordID]= " & varID
if not me.recordsetclone.nomatch then
end if

LVL 11

Accepted Solution

datAdrenaline earned 500 total points
ID: 36891851
Since you are likely not having to worry with any deletions, I would consider going a little "lower level" than caps suggestion (assumption is the the pk field is an autonumber and is named RecordId).

Dim lngId As Long
lngId = Me.RecordId


Me.Recordset.FindFirst "[RecordId]=" & lngId

{note: definately not indicating there is anything incorrect with caps suggestion!}

Author Comment

ID: 36891864
To be sure

Dim varId is a module variable

       varId = me.recordId
is  in click event (detail button)

      me.recordsetclone.findfirst "[recordID]= " & varID
      if not me.recordsetclone.nomatch then
      end if
is in Form_Current event

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

LVL 11

Assisted Solution

datAdrenaline earned 500 total points
ID: 36892309
Not really ... the key is this ... When and How to you tell the main form to Requery?  Do you have code in the Detail form that requeries the Main form? or do you have an event that is triggered when the main form recieves the focus again?

Wherever that call to .Requey exists, you need to surround that call with a way to store the value of the current record (I would recommend a procedure level variable, not a module level variable), then the .Requery is called, then you perform the .Find.

Author Closing Comment

ID: 36893098
Solution used:

In details Form, on click event (closing button)

Private Sub btnClose_Click()

   Dim strActiveRecord As String

   strActiveRecord = "[trainingNo]=  '" & Me.txtTrainingNo & _
                                   " ' AND [departmentId]=" & Me.lstDepartment
   Forms. mainForm.Requery
   Forms. mainForm.Recordset.FindFirst strActiveRecord

End sub
LVL 119

Expert Comment

by:Rey Obrero
ID: 36893713
? :-(

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
View vs Edit mode enhancements 12 40
Unrecognized Database Format 8 93
MS Access Calculation wont work 5 36
how to link subforms ms/access VBA 6 30
In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now