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
3 1069
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)
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?
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 -
Private Sub Report_Open(Cancel As Integer)
-
-
Dim Args As String
-
-
ReportCancelled = False ' Global variable
-
-
Me.Visible = False
-
-
DoCmd.OpenForm "DateEntry", , , , , acDialog, Me.Name & "~-32764" & "~SignInDate" ' Name, Report & Date to filter on
-
-
If ReportCancelled = True Then ' Cancelled from Date Input form
-
Cancel = True
-
End If
-
-
End Sub
-
This then opens this form (It's title is passed from the Menu)
After entering both dates the Run button does this: -
Private Sub Buttonrpt_Click()
-
-
Dim Rpt As Report
-
-
'Blah Blah Check Dates OK (Code omitted)
-
-
If IsReportLoaded(RptName) Then
-
Set Rpt = Reports(RptName)
-
Rpt.Visible = True
-
Rpt.Filter = DateField & " Between #" & Format(FromDate, "Medium Date") & "# AND #" & Format(ToDate, "Medium Date") & "#"
-
Rpt.FilterOn = True
-
End If
-
-
If IsNull(FromDate) Or IsNull(ToDate) Then
-
If IsReportLoaded(RptName) Then
-
DoCmd.Close acReport, RptName
-
End If
-
End If
-
-
DoCmd.Close acForm, Me.Name
-
-
End Sub
-
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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?
|
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...
|
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...
|
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"...
|
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,...
|
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...
|
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...
|
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
|
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...
|
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...
|
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...
|
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,...
|
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...
| |