Requery report on Navigation Form (1 Viewer)

BillJovi

New member
Local time
Today, 01:34
Joined
Feb 1, 2013
Messages
2
Hi,
In Access 2010 I have a standard Navigation form with sub-navigation. On one of these sub-navs is a report which I would like to be able to initially query using the current date and after the report is displayed, to have the ability for the user to enter a different date and re-display the report. The first part I have ok, but I cannot find the report in the sub-nav to close it and any calls to open the report simply open another tab window. Does anyone have any experience of this?
Thanks.
 

mdlueck

Sr. Application Developer
Local time
Yesterday, 20:34
Joined
Jun 23, 2011
Messages
2,631
Would not the design work to have the Report bound to a DAO.QueryDef object. Use VBA code to dynamically build the DAO.QueryDef with the current date initially built into the SQL. If someone should desire to change the data, simply update the SQL in the DAO.QueryDef, then send a Requery event to the Report.

Sample code to build a DAO.QueryDef object:

Code:
  Dim daoDB As DAO.Database
  Dim daoQDFfe As DAO.QueryDef
  Dim strQryNameFE As String

  'Attach to the FE DB
  Set daoDB = CurrentDb()

  'Build the FE Query
  Set daoQDFfe = daoDB.CreateQueryDef(strQryNameFE)
  With daoQDFfe
    .SQL = strSQLfe
    .Close
  End With
 

BillJovi

New member
Local time
Today, 01:34
Joined
Feb 1, 2013
Messages
2
Hi Michael,
Thanks for the reply.
I've used querydefs before but the issue I'm having is how to send the requery event specifically to the 'open' report I can see on the screen in the sub-navigation. In the debugger, I've traversed the Application object graph but I just can't seem to reference this report. The issue is getting the reference to the report in the sub-navigation screen (if that makes sense?).
 

mdlueck

Sr. Application Developer
Local time
Yesterday, 20:34
Joined
Jun 23, 2011
Messages
2,631
how to send the requery event specifically to the 'open' report I can see on the screen in the sub-navigation. In the debugger, I've traversed the Application object

In Form code, the Form may refer to itself as Me.

Put for example

Code:
Me.Refresh

in a button click event, set a BreakPoint on the Button Click event, and have a watch set on the Me object, context all methods of the one Form.

Then you may drill down in the Me object, you should see the navigation control, on that control you should see your Report object, and send that object name path the Requery event when you have updated the DAO.QueryDef's SQL.
 

Users who are viewing this thread

Top Bottom