Set Value to a Report Textbox from a Query - database

I made a query that only shows me a single field and a single record from another query, how can I put that value in a textbox in a report?
The record I want to set is a date that I insert with a MsgBox.
I read that there are ways to just put in the Control Source "=[table]![field]" but I get the Name? error, another way I read but did not understand it is defining a recordset. I can't put the value to the textbox despite trying the ways I've read in other posts.

One simple way is with DLookup() domain aggregate function expression in textbox. If field name has space or punctuation/special characters or is a reserved word, [ ] delimiters will be required. Usually table/query name does not but can't hurt.
=DLookup("[fieldname]","[tableORquery name]")

Related

"EmptyHeader" in CSV Export Options?

I have a CSV file I am attempting to create, and the recipient requires a header row. In this header row (and in the data) there is a field that used to be present that was removed. However, they did not remove the column that that held that data, so now, there is an empty column name surrounded by delimiters ("|"). How can I recreate this?
The expected results for the following columns should be:
RxType1|RxType2|RxType3|RxType4|RxType5||DelivID
(There is an empty column between RxType5 and DelivID) and the results would be:
|Rx|OTC|Legend|Generic|Other||Express
I am using SSRS, and have attempted adding an extra pipe the the column header for RxType5 with an empty column behind it, but the CSV seems to generate a header row based on the column names from the stored procedure and not from the RDL data. I have also attempted in the Stored Proc to create the column by using:
Select
'' AS ""
OR
'' AS "|"
but when I refresh the fields in SSRS, it puts that the column is called "ID_" (because a space, no character, or pipe is non-CLS compliant.
Any suggestions on how I can achieve this? Thanks so much :)
Try creating the column with a known name, like SELECT '' AS [RemoveMe], and then just remove that name from the row header text box.

Xtrareport DevExpress Keep Table together with the first record

I have some data that I want to be displayed the following way and I cannot find how to do it:
For example this would be the keep together case:
But I don't like that I have a lot of blank spaces when data is too much, so I would like the following to happen if possible.
When the colNames and the first row can fit in the remaining space put them there.
Or if more can fit after the first row, put all of them there and split where it is possible if necessary.
Basically I want a 'Keep together' option for the columns and first row, and everything else can be splitted at any point.
If anyone wants to achieve the same functionality do the following:
Put the table column names inside a GroupHeader and set its GroupUnion property to WithFirstDetail.
Put the table rows in the Detail next to the GroupHeader.
By doing this the WithFirstDetail property, as the name suggests, will try to keep the header with the first record, or move to the next page. Therefore achieving the behavior described above.

Printing records with condition Crystal reports

I am using stored procedure in mssql as backend, vb.net as frontend (just info).
There are a lot of records in the database and I am printing in crystal reports.
Now I want to filter the records from crystal report and not by adding a new parameter to procedure or changing database structure or else.
For now,Say there are columns : Name , Amount.
I want to put filter in amount like only display records whose amount above 100 or something. So other records with less than 100 should not be displayed.
This filter will be passed by the user so it'll be random.
I can't find a proper answer on internet. Might be a duplicate question, if so please post the link of the question if it is duplicated.!
Thanx anyways...!
In general the idea is to:
Create the parameter (user choose what will be the input/value) - link
Set filters, what values should be displayed in regards to parameter - link
On right side there is a DataExplorer window, where You need to add a Parameter (define his name, what question will be shown to user and what type the param will be / what values can be set inside).
Once done, You can jump to Data tab of a report, click Interactive Filter and specify which column must fit what condition with what value = Parameter (that one user will enter in Report).
Example: I will create AmountParam, with message "What should be the minimum amount?". Type will be set to Integer. Going to Report->Data->Interactive Filter, choose Amount as a Column, AmountParam as a Parameter and set condition Greater then (>).

Pass field from one dataset to another dataset as parameter In SSRS 2008 R2

I have a scenario where one of my data-set returns multiple records. Now I have implemented grouping in my report so as to display each record from this data set on a different page.
Now I have an another dataset which loads some data using fields from dataset1 as parameter. That means I need to assign the fields from dataset1 to dataset2 as parameter for each record.
For a single record, we can assign the values from dataset1 to a report parameter and then use it for our dataset.
But in this case, parameter always holds the value 1st record and passes it for every page or group.
How can I achieve this?
I had the same problem, where the value was always from the first record in the parent report dataset for each subreport record.
In my case, the resolution was to remove the hidden parameter that I was using in the parent report. The default value I was assigning for that parameter were results from a query.
I then went into the properties of the Subreport, selected Parameters and in the Value dropdown where I originally assigned my parent report parameter, I switched it to the field name of the parent report dataset field so that it would pass the value to my subreport parameter.
Hope this helps.
I may be misunderstanding your question, but I think what you're looking for here is the LookUp() function. This basically fetches data from another dataset, matching on some primary key that you define.
The function has four arguments; the first is the data to match on in the "destination" dataset (I.E. the one that's currently powering your matrix, the second is the data to match on in the "source" dataset (I.E. the one you're fetching the data from). The third is the data you want to fetch, and the fourth is the name of the "source" dataset.
So as an example:
=LookUp(Fields!PrimaryKey.Value, Fields!PrimaryKey.Value, Fields!Data.Value, "DataSet2")
The result of this expression would be for the Report to bring back the data from the field called "Data" in "DataSet2", matching on the values in the fields called "PrimaryKey" in each dataset
Hope that makes sense.
From your explanation, it seems like you want to use a for...next loop but only the first item in Dataset1 is always returned. Did you try to clear the parameter before the loop goes to the next item? Another alternative is to create a Dictionary and add all the items in Dataset1 to it, then loop the Dictionary to get the records for Dataset2, and always clear your parameter before the loop goes to the next item. There should be much better options, but this is what I have for now.
Regards.

DLookUp behavior in Form_Current with Label Captions

Access 2010 here.
Ok, Dlookups appear behave different based on where they are used. I have this Dlookup
inside a ClockNo_AferUpdate() subroutine that works well on new form entries to change a label's caption to what is found in the "Employees" DB under "EmployeeName" field based on the entered "ClockNo" in a ClockNo combo-box:
Me.LabelName1.Caption = DLookup("[EmployeeName]", "Employees", "[ClockNo] =" & Forms![InspectionEntryForm]!ClockNo)
The Employees database has four fields: AutoNumber-type "ID," Number-type "ClockNo," Text-type "Shift," and Text-type "EmployeeName."
Re-EDIT:
The RowSource for the ClockNo combo box as it sources from the Employees database:
SELECT DISTINCTROW [ClockNo], [EmployeeName] FROM [Employees] ORDER BY [ClockNo];
END Re-EDIT
What I am looking for is the same functionality in Form_Current() so browsing through older entries preserves the Label's caption based on the entered ClockNo. Unfortunately, simply re-using the above Dlookup gives a "Run-time error '3075': Syntax error (missing operator) in query expression '[ClockNo] ='."
Attaching the Dlookup as a control source to a text box does work O.K, but labels seem to be the best use here. I have mucked about with the Criteria section of the Dloopkup for some time without any real success.
End goal is to have a simple label next to a combo box that displays the employee's name based on their current and past ClockNo entries. The name is stored in a separate Employees database alongside their clock number and their shift.
This should be quite simple as both the ClockNo entry and the Label operate on the same form with the same database. Thanks for your input!
You have a combo box named ClockNo with this as its Row Source:
SELECT DISTINCTROW [ClockNo], [EmployeeName]
FROM [Employees]
ORDER BY [ClockNo];
I'm not sure why you want DISTINCTROW there. I would have suspected DISTINCT to be more appropriate. But I don't think it matters.
The important point is that the combo already includes [EmployeeName], so you shouldn't need to use DLookup to fetch [EmployeeName] again. Simply read the value from the second column of the combo's selected row.
Imagine your form includes a text box named txtEmployeeName. In the form's current event, you could do this:
Me.txtEmployeeName = Me.ClockNo.Column(1)
Notice the column index numbers start with 0, so the second column is .Column(1).
And you could do the same thing in the combo's After Update event.
Finally, you wanted to change a label's .Caption, but I showed you how to change a text box's .Value. If you can't make this technique work with the label, just use a text box instead. You can set the text box's Enabled property to No and adjust its other properties so that it is visually indistinguishable from a label.
Another approach could be simpler still. If you want to keep [ClockNo] as the combo's bound value, but are willing to display [EmployeeName] as the combo's selected value, you can set the width of the first column ([ClockNo]) to zero. You would still see both [ClockNo] and [EmployeeName] in the dropdown. If this is acceptable, you wouldn't need to bother with a label or text box.

Resources