format report group header - ms-access

Thank you for your reply,
I have a report then contain 7 group levels. I want if a field that is in groupheader7 (ThirdCenterCode) was null, it’s group header ( groupheader7) visible property be set to No.
and it should be control for each rows. Because it my in another record, that field is not null and group header 7 should be shown.
I try this code in format property of group header 7, but it not work and return the below error:
Private Sub GroupHeader7_Format(Cancel As Integer, FormatCount As Integer)
If IsNull([ThirdCenterCode]) Then
Me.GroupHeader7.Visible = False
End If
End Sub
Run-time error ‘2465’:
Microsoft access can’t find the field ‘ThirdCenterCode’ referred to in your expression.
Thank you a lot
With best regards
Ehsan Shahidifar
e.shahidifar#yahoo.com

In the VBA of a report, you can't refer to fields in the reports underlying recordsource unless there's a control on the report that uses that field as its Control Source. This was not always the case.
So, if you want to check the value of Me!ThirdCenterCode, then create a control and set that as its ControlSource, and then sets its .Visible property to No.
Of course, if you already have a control with ThirdCenterCode as its ControlSource, that is not the answer, and it's more likely a case of simply misspelling the name of the field.

The error is usually true enough. Double check the spelling - it can be useful to use intellisense to find controls and fields associated with the current form or report, you can do this by typing Me. and seeing if it is listed.

Thanks for your replay.
I found that Cause of error message, was the wrong location of it. It should be locate on detail section of report. Then I locate it in OnFormat of detail section of report. I found that if only one record of first group be Null Access will not show the ThirdCenterCode Section for all rows of current first group data. And it is not that I want, because there are some rows of data that ThirdCenterCode field of them are not Null and should be shown.
For solving this problem I locate my code in OnLoad section of report and it solve my first problem,
But Led to another problem. In this section access doesn’t show me the ThirdCenterCode Group section if all of records were null and if Only one record was not null, Access show the ThirdCenterCode section. And it causes that one or more rows in my report became blank.
Finaly for solving this problem I Copy and Paste code Of OnLoad section of report to OnPrint of Detail of report. Disbeliefly I found that when report is shown, my last problem is not solved. But when I print report, my problem is solved. ( It means that if ThirdCenterCode is Null Access don’t show it’s section group , and if it is not Null Access show it for each record.)
Best wishes
Ehsan Shahidifar
e.shahidifar#yahoo.com

Related

Error occured during local report processing valid values are between '0' and '1'

Trying to render an SSRS report that had a multi-select parameter option and multiple row groups within a single tablix. The report would fail inconsistently with the error message above. Entire error message was, "An error occured during local report processing. The value '3' is invalid. Valid values are between '0' and '1'. This error message is not obvious.
The issue with the report was that there was a page break set to be between each instance of one of the 3 groups mentioned in the question. The tablix which contained the three groups also had the property "keep together on one page if possible" set to true. It seems that these two properties do not play nice together. Setting the keep together property to false allow the report to generate.
Link that led to answer, not officially marked as answer in this forum. Posting so its easier to find.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/c6693ff7-e407-4279-95c1-33184ebb9401/rrrenderingerror-after-upgrading-to-sql-server-2008-r2?forum=sqlreportingservices

Filtering in subreport

I have encountered issues with using "filtering menus" in report during development of database aplication for my employer.
For my filtering options I created buttons with OnClick Event:
DoCmd.GoToControl "MyReportField"
DoCmd.RunCommand acCmdFilterMenu
These buttons are embedded in subreport. Initial thought was to create buttons, similar to the one in ribbon, with filtering options (in final stages of development I am planning to disable/hide Access ribbon for users). I created 5 buttons, 3 for fields with data type Text, 1 with data type Date and 1 with Boolean data type.
To quote a classic, the buttons "are misbehaving." When I test their function in form in form view, the "BooleanFilterBtn" on click already doesn't display Yes/No options (or something similar), but displays 2 numeric values (like -24441 or -29696). And filter is not working whatsoever.
Another problem arises when I try to have active more than one filter at a time. Date field filter and one of the Text field filters are working when combined with another filter option. But after using one of the two remaining Text field filters, when I click any other of the filtering buttons, the FilterMenu becomes blank.
Worth noting is that right-clicking on given field in report works without issues, but not the way I want.
Given these rather odd behaviours I think I am missing something. Is there a way how to make FilterMenus work the way as familiar from the ribbon? If not, is there any other option with similar design, options that I could try out?
Additional info:
Subreport is connected with form through "MyIDField." Both subreport and form have query data source, already saved.
All field names and data types are matching.
EDIT: Also I should have written that the FilterBtns doesn't work if I open the subreport separately, they work only when I open form (with subreport in it), eventhough the FilterBtns are using only controls from the report.
EDIT2: Code behind filter button filtering Boolean data type (boolean data are in Report in form of Yes/No check-fields, as mentioned in June7 comment bellow):
Private Sub btn_FiltrGarant_Click()
DoCmd.GoToControl "Garant"
DoCmd.RunCommand acCmdFilterMenu
End Sub
When I change this code to:
Private Sub btn_FiltrGarant_Click()
Me.Garant.SetFocus
DoCmd.RunCommand acCmdFilterMenu
End Sub
Brings no effect, only that the loading time of actual FilterMenu takes a bit longer.
Example for Text data type field:
Private Sub btn_FiltrRzh_Click()
DoCmd.GoToControl "ZkracenyNazev"
DoCmd.RunCommand acCmdFilterMenu
End Sub
Changing code in the same manner:
Private Sub btn_FiltrRzh_Click()
Me.ZkracenyNazev.SetFocus
DoCmd.RunCommand acCmdFilterMenu
End Sub
Brings no effect too.
May it be that the FilterMenu is not meant to/available to be used in reports? Or may it be disabled in default settings of Access?
Because also the situation, that if I open the Report separately (not in form as a subreport, but just as report by itself in report view), using any of the FilterBtns gives me RunTime error 2046, that the action GoToControl is not available. Changing to SetFocus eliminates the error, but the button doesn't bring up any FilterMenu at all. But these issues are valid only if I open report separately (which is not my interest), but might be helpfull as information.
Right now, I don't know where the problem could be. Anything I could think of was data type/naming mismatch, but that's not the case.
FINAL EDIT: After almost a month (there were holydays) of trying and searching for a way how to make this setup work I decided to switch from subreport to subform, in which I will try to obtain the same functionality.
Maybe just reports are not supposed to be handled the way I wanted to.
Just out of courtesy I am putting June7 answer as verifiedfor the time spent on helping me.
Thank you.
Don't know why your yes/no field displays 2 numeric values like -24441 or -29696 in the filter menu. Regardless, not able to get the filter menu to act on a yes/no field at all. However, get around that with an expression in report RecordSource query that changes the Yes/No field from Boolean to text values and use the calculated field in report design, like:
SELECT *, IIf([fieldname], "Yes", "No") AS IsSomethingTrue FROM tablename;
Use Me.controlname.SetFocus instead of GoToControl so the report will open independently or as a sub object.
You have to be careful how you refer to a Report object that is within a subForm container. They do not behave the same as subforms in many ways.
Even a simple refresh is actually difficult to achieve, as reports are not meant to be dynamic like a form.
To refer to it in VBA you have to use the full form syntax;
[Forms]![MainFormName].[Form]![subReportHolderName].Requery
Using the normal Me.blah.blah reference will not work with a form embedded report. Note that you refer to the container - NOT the report object.

ssrs if - cannot print the requested value

I have the following iif
IIF(LEN(Fields!IDENTITE.Value)=0,"Known manager","Unknown manager")
Yet for some specific case, nothing is appearing (e.g. no known nor unknown)
I checked the results with a sql query and nothing is appearing (the result is below)
I amended my iif to reflect this case
IIF(COUNT(Fields!IDENTITE.Value)=0,"Known manager","Unknown manager")
Yet the same issue is appearing
Any ideas on the why?
Thanks
Update : I tried the countrows as mentionned by #breez and I got this error
One of the possible way to deal with the absence of rows is the following:
Click on the tablix , look for NoRowsMessage option and type the text you want (example: "No known managers")
Next time there are no rows, this message will be displayed
PS: It is only doable for matrix, list and tables not for textbox. For more info, click here

Parameter is missing a value ssrs 2008

I have a parameter of integer datatype which is hidden. When i run the report, report gives me an error
Parameter X is missing a value
However if i make the parameter visible it works. I tried providing default value of 0 but that does not suffice my requirement as i have sub-report(Drill-dowm) depended on this parameter. Please help. Thanks!
Make sure that you have not specified Available Values for the parameter. Available Values should be "None" for internal and hidden parameters.
First of all,
Check that parameter's - Available Values by going to report parameters properties.
It must not be specified any values. So we should set it as None
Second work around is,
Just add a blank space at Specify values - in Default values inside report parameters properties.
This will surely work. Hope it will save your time.
I had to do an "if exists" statement for this to go away. It worked for me because it makes it always return a value even if that value is not need by my query.
if exists (my select query)
my select query
else
select '2'
// '2' would never be used, but it made ssrs stop giving me
// the stupid error and execute the rest of the query
If you specify available values from query, then default values must be in list of available values. Default value in (Available) = true.
The problem occurs also, if you have a parameter that depends of another one without "default value" inside the Dataset Query and does not admit null value.
For example:
Parameter 1 have a default value: NameEmployee from the dataset "EmployeeSearch"
But the dataset "EmployeeSearch" have a filter or a parameter inside the query named #Month that indicate the number of the month. So if the value of #Month is null, SSRS will say "Parameter is missing a value".
Assuming you had the same issue as I had, trying to run the report on a web page using a ReportViewer component, I managed to fix that issue by adding a null parameter before rendering the report:
C# code:
var parameters = new List<ReportParameter>();
parameters.Add(new ReportParameter("ParameterName", (string)null));
ReportViewer1.ServerReport.SetParameters(parameters);
Hope that will help
Just need to add 1 default value to get around this error (even though that default value will never be used).
-Under "Report Parameter Properties" for that specific parameter, go to the Default Values page.
-Toggle "Specify values"
-Add a value (I added: "just_a_filler_to_get_around_hidden_value_error" so when I look back at it later I remember why I did such a thing)
-click OK
I want to add to dmbreth's CORRECT answer.
I was missing the concept that the value of the parameter still needed to be tied to something. Originally, I was tying the output of a dataset by using the Available values portion of the parameter properties, but according to dmbreth's answer, that could not be the case. Finally I moved my output dependence settings from the Available Values section to the Default Values section and that did the trick.
So, in summary, in the parameter properties dialogue:
General Page - Allow multiple values checked(this option is specific to my application), parameter visibility set to internal
Available Values Page - None
Default Values Page - Get values from query, [appropriate dataset, value here]
Advanced Page - No significance here
Hopefully, that is clear enough to benefit someone else with the same problem...
I had a similar issue where the default value as set by SSRS is (Null), I didn't need the parameter for my report however; I found it useful for testing to filter down the list so I kept it, I guess I could have deleted it in SSRS on the dataset config. but I changed it to =System.DBNull.Value (I guess this could be any expression) instead and that worked for me, so then I can still pass in a value if need be and also set Available values (had to make sure a NULL value was added to my dataset) if I then decide to unhide at a later date.
There is one other potential here. I have had a situation where the report designer works but the server report object does not. The solution is to delete the server object and then re-save it from the designer.

How do I query a property on a record source for a Access 2002 report in code?

In the 'code behind' of the report is there anything I can do in code to query a property of the record source.
Sorry I'm new to access and VB, but I am wanting to achieve something along the lines of this
If Me.RecordSource["MYFieldName"] = "dan" Then
//do something
End If
Is this possible?
The only method for examining values in the recordset of a report is to have the field bound as the ControlSource of a control on the report. If it's a field that does not need to be printed on the report, then you have to add an invisible control. Deciding whether to place it in the form's header/footer or in the detail will depend on the layout of your report and what kind of data you're attempting to examine.
You used to be able to do this directly in A97 (without a hidden control), but the results were often confusing, as the data buffer behind the report is often one record ahead of what is displayed onscreen.
Also, you have to be careful which events you try to use, as the data in a report has a very different relationship to what is displayed than is the case in forms. That is, certain events cannot refer to data or controls because they happen at times where the controls do not really exist (or do not have any data in them).
In general, the only events I use in reports are OnOpen, OnNoData, OnClose and the Detail's OnFormat event, and I use them to set recordsource, controls sources, control width/visibility and to draw lines, and not much else.
EDIT: In another answer, #GuinnessFan points out something I didn't know, and that's that if you have a control on your report that is bound to the underlying field you want to refer to in code, you can do so. For instance, if you have a field called "Phone" in the underlying RecordSource and a control "txtPhone" bound to it, you can refer to Me!Phone directly in code.
My guess is that what's going on is that Access is setting up a VBA-usable wrapper only for the fields (i.e., the old hidden properties that are why you get compile-time checking of references like Me.Phone) that are used as ControlSources.
But it is still the case that to use the values from the underlying RecordSource in code, there has to be a control with that field as ControlSource, whether it's hidden or not. The new information is that you don't have to use the control name to get the value. This means it's possible to distinguish between the displayed value for a field and the value in the recordset behind the report, which are not always in alignment. I think that in general, in most situations you'll want to use the control value, as it's not clear whether the cursor of the underlying recordsource is on the same record as the one that's being displayed. Also, if you use page-level events for a report that displays more than one record on a page, it won't be obvious which record you'll be getting the data from.
If you want to do something every time the report comes across "dan"
Private Sub Detail_Format(Cancel As Integer, PrintCount As Integer)
If [MyFieldName] = "dan" Then
' do something here
End If
End Sub
For things like, "I want this field to have red text" you should look into Conditional Formating.
Used detail_format instead of print. [MyFieldName] instead of Me.MyFieldName