Link to home
Start Free TrialLog in
Avatar of Donovan Moore
Donovan MooreFlag for United States of America

asked on

VBA: Select Next Record on Subform After Refresh

I have an MS Access application that uses a dialog box with various selection criteria to run a report.  Once the report has run, I update a timestamp that displays on an underlying subform.

What I'd like to do, is to run the report, and on closing the report, refresh the subform (contained within a separate form beneath the dialog box), and select the next record in the subform.

Summary:

 1. Run report from dialog box with selection criteria.
 2. On report close, refresh the subform within the underlying form.
 3. Select the next record that follows the one previously run.

Hopefully, this makes some kind of sense.  I think this SHOULD be relatively easy, but I'm getting stuck on syntax.

Please let me know what else I can provide.
SubformRecordSelect.png
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

re:>  refresh the subform within the underlying form.

Why you need to refresh? Has its date changed?

When you close the report, the focus returns to the form and OnActive event of the form fires.

I will give you more detailed info later. In a public variable, you will store the PK of the record you want the form to show e=when the report is closed. Then in OnActive event, you can use bookmark to move to the record with PK you have stored in the public variable we talked about.

Mike
Avatar of Donovan Moore

ASKER

Sorry for not explaining - running the report sets the generated date.  I want to refresh the subform to show the new date.
Public lngPK as Long
for now put this in a module outside the form, later on we may be able to bring inside the form in question.


In on Active event of the main form (not subform) have:

Me!SubromName,FormRefreshSubform

In subform after decorations have

Public Sub  FormRefreshSubform()
  MsgBox "FormRefreshSubform fires ok"
End Sub

Apply these until first you get "FormRefreshSubform fires ok" message. We will continue.

Mike
ASKER CERTIFIED SOLUTION
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I got it working...differently than what was suggested, but you certainly got me pointed in the right direction.  Thanks!