473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Get RecordSource of closed report.

PhilOfWalton
1,430 Expert 1GB
I am trying to extract the field name from a report's RecordSource.

I can't open the report in Design View, as eventually I want the database saved as ACCDE.

I can't open the report hidden as it needs parameters to run.

So for example, suppose 1 report needs a date range. I want to save the name of the field (DateField) in a table, and on opening the report, it opens a form asking for the From Date and To date for "DateField"

Another report needs an Employee range, so save "EmployeeID" in the table and the same form opens asking for From Employee To Employee.

Don't think it can be done, but anyway, it's worth asking.

Phil
Jul 27 '16 #1
3 1069
nico5038
3,080 Expert 2GB
The requirements are a bit confusing, but all report controls can be managed by VBA.
So I once created a dynamic report to fill crosstable fields by naming them from the fields collection of the DAO recordset. Also using the .tag property of the field attribute or fixed names could be worth investigating...

Nic;o)
Jul 27 '16 #2
jforbes
1,107 Expert 1GB
I understand most of the mechanics you are looking to perform but I'm not exactly sure what you are attempting to accomplish and why.

It sounds like you are creating a Form to dynamically provide a Filter for a Report and then launch the Report. What confuses me most is that you say the report takes parameters to run. Typically, mixing Filters and Parameters isn't done; it's usually one or the other.

Not only that, in my experience, when creating a Form that inspects another object in Access, like another Form or Report, it is done as an Administrative Form, to inspect the object and then save things off into table that would be then used by users at runtime. In this case opening the other object for inspection in Design mode or running a Form or Report with a filter of "1=2" so that nothing is returned, even though it acts all crazy, is usually OK.

Again, what are you attempting to accomplish?
Jul 27 '16 #3
PhilOfWalton
1,430 Expert 1GB
Thanks for replies. I have had a complete change of mind as a result

What is currently happening is I open the report from a "Menu" and set it's Visible to False

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer)
  2.  
  3.      Dim Args As String
  4.  
  5.      ReportCancelled = False                ' Global variable
  6.  
  7.      Me.Visible = False
  8.  
  9.      DoCmd.OpenForm "DateEntry", , , , , acDialog, Me.Name & "~-32764" & "~SignInDate"    ' Name, Report & Date to filter on
  10.  
  11.      If ReportCancelled = True Then              ' Cancelled from Date Input form
  12.          Cancel = True
  13.      End If
  14.  
  15. End Sub
  16.  
This then opens this form (It's title is passed from the Menu)



After entering both dates the Run button does this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Buttonrpt_Click()
  2.  
  3.     Dim Rpt As Report
  4.  
  5.      'Blah Blah Check Dates OK (Code omitted)
  6.  
  7.     If IsReportLoaded(RptName) Then
  8.         Set Rpt = Reports(RptName)
  9.         Rpt.Visible = True
  10.         Rpt.Filter = DateField & " Between #" & Format(FromDate, "Medium Date") & "# AND #" & Format(ToDate, "Medium Date") & "#"
  11.         Rpt.FilterOn = True
  12.     End If
  13.  
  14.     If IsNull(FromDate) Or IsNull(ToDate) Then
  15.         If IsReportLoaded(RptName) Then
  16.             DoCmd.Close acReport, RptName
  17.         End If
  18.     End If
  19.  
  20.     DoCmd.Close acForm, Me.Name
  21.  
  22. End Sub
  23.  
This works fine, but as I said, I have had a complete re-think and realised I can set the Arguments from the OpenReport to "Re-Design" the date form to show whatever fields I want to use as the Report Filter.

Your answer put me on the right track. This should be fun!!!

Phil
Jul 27 '16 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sigurd Bruteig | last post by:
In forms it is possible to use different SQL strings as recordsource. In report this is not possible to do the same way. What I want to do is open a report from a button, and be able to give...
2
by: Koen | last post by:
Hi all, I've struggled with the following problem and welcome all a suggestions to solve this. I have a form that list records from a table with observations. The record source for the table...
1
by: James Fortune | last post by:
In order to get the records I want on a report I sometimes create a SQL string for the RecordSource and sometimes supply the criteria using the Filter Property. If I use the Filter Property rather...
2
by: Rick Caborn | last post by:
I am having a problem with an Access 2000 report getting data from SQL Server 2000. Here are the specifications for it: RecordSource: a stored procedure (tested via query analyzer and working...
1
by: Michael Wiseley | last post by:
Does anyone know what kind of code to use read the recordsource of a report that is not open?
2
by: Gerry Abbott | last post by:
Hi all. Im using a form's recordsource for a report. which works fine Me.RecordSource = Forms("frmdate01").Form.Controls("HoldLog").Form.Controls("frmHoldLog01").Form.RecordSource Ive got a...
1
by: vendredi5h | last post by:
Helle all, I'm using A97. What I'd like to do it's to find all the reports in my DB that have a certain string in the record source. Say, I'm looking for all reports that have the table...
28
by: ryanhokanson | last post by:
I was just trying to get a list of all my reports along with their widths. I can't use the "Reports" collection because it only works on open reports. So I tried looking into the "AllReports"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.