Need a macro to validate the the template - macros

I have a template contains a list of headings (B1 to B25) and the corresponding related data. I need a macro such that if I run this macro, It should show the mistake in the header cell number
For example, take a student record having these column headings:
(sheet name=Student)
Sno, name, class, sub1, sub2, sub3, sub4, sub5, sub6, total, grade,...etc.
If I run a macro with an error in B3 value ="Cass" then it should show the error message as "Error in B3".

Related

Access 2010 - enter references to form elements as the value of a text field

Is there a way to take a value from a field on a form and use it as a reference to a different field in the same form, and not just literally? I want to be able to manually enter something like [txtFlavor] in one field and have it show the actual flavor, the value of the field named "txtFlavor" in another field, and not just the string "[txtFlavor]". I'm basically trying to store some vba references (terminology?) in a table so I can bring up a string of text with references to values on the form.
I have been asked to create a system that will store letter templates in Access 2010 and allow users to choose a record with personal information and insert that info into a template letter, preferably displaying it on a form immediately in plain text. I already proposed using reports to do this but that was unacceptable to the end users. They really just want a form that combines
a) contact records, one at a time
with
b) letter templates, one at a time
I've been trying to store the template info with it's form references in a table, but I have yet to be able to make references pull data from another text field on the form.
Is it possible and/or sensible to try to store something like the following in a table, or to enter it into a field on a form?
[txtFlavor] & " is dull but popular."
and then have it show up elsewhere in the form as
Vanilla is dull but popular.
I sure feel dumb and am sure I've missed something obvious. Everything I do is just repeated literally and not interpreted as a reference.
You could get your users to create their templates using 'tags' as placeholders for the database information, in a similar way to how you would design a merge document in Word. So in your example above, the template document would look like:
{Flavor} is dull but popular.
When it comes time to create the merged result you would need to use the Replace function to change these tags to actual data values. So if you had a read-only text box on your form, the control source could be:
=Replace([txtTemplate], "{Flavor}", [Flavor])
I assume you would have lots of potential tags, so using this approach you would need to nest the Replace functions. I have split my nesting across multiple lines to make it a bit more readable:
=Replace(
Replace(
Replace([txtTemplate], "{EmpName}", [EmpName]),
"{EmpAddress}", [EmpAddress]),
"{EmpPhone}", [EmpPhone])
If you had many more database fields/tags this would start to become very unwieldy so I would recommend using some VBA to make life easier, maybe something along the lines of:
Dim rsSource As Recordset
Dim strMerge As String
Dim intField As Integer
'Assuming your form has a field called EmpNo (numeric data) that you can use to pull data...
Set rsSource = CurrentDb.OpenRecordset ("Select EmpName, EmpAddress, EmpPhone From Employees Where EmpNo = " & Me.EmpNo)
strMerge = txtTemplate
For intField = 0 to rsSource.Fields.Count - 1
strMerge = Replace(strMerge, "{" & rsSource(intField).Name & "}", rsSource(intField))
Next intField
txtMerge = strMerge
rsSource.Close
Set rsSource = Nothing
You could put this code in the AfterUpdate event of your txtTemplate text box and it would update the contents of the txtMerge text box. You either need your tag names to match your database columns, or else you could alias the columns in the Select statement so they match the tag names.

SSRS does not work when input parameter has a + sign

I'm creating a report which has as input parameters: id and name. These parameters are used in the where clause of the select from which I get the records to display in my list.
The problem is that if there is a + sign into the name the parameter (that I print on the page to display the filter) name appears with a space instead:
Input parameter = "record+story"
Parameter shown in report: "record story"
So the result of the select is empty, since the name doesn't match!
What am I missing?
EDIT: I open the report through a client application, based on VB6. There is a main page with a table and a list od ids, when I click on a row of the list it redirects me to an IE page performing the filtering and showing only the needed data.
The parameters are: id - Integer, and name - text.
When it opens the IE page I see that if the name contains a plus sign there appears instead a space, which of course is wrong, therefore the resulting report is empty.
I already tried to add the System.Web reference to VB6 in the client application, but it doesn't work.
Here a picture to clarify what I mean.
Thank you
C.
In the end I got the solution. I only need to encode my parameter so that the + sign is read as a + sign. This is achieved by using the hex value in the code behind:
example: namewithplussign ==> replace(namewithplussign , "+", "%2b")

JasperServer - null values for input controls

Recently I got some help with grouping when a user enters a null value into an input control ("Rolling up" groups in Jaspersoft iReport). I am using iReport/JasperServer Professional 4.5.1. My three levels of grouping are pharmacy, facility, and packaging type.
After deploying the report to JasperServer, I am having some trouble with nulls. I unchecked "always prompt" for my input controls, and when the report opens the first time it acts as though it has received null values for all input controls and groups appropriately (which is what I want). The display mode for my input controls is "in page", so they're displaying on the left-hand side of the screen. When I then try to select one pharmacy and re-run the report (expecting aggregate values for facilities and packaging types, since I didn't select anything for those controls), the report performs like the aggregate code doesn't exist, and lists all facilities and all packaging types.
However - if I save that one selected pharmacy as a saved input control, then go back out to the repository and run the report using the saved input control, it works fine, and aggregates all facility and packaging type data.
Any thoughts?
Thanks,
Lisa
My input controls are multi-select queries and my parameters are collections. I discovered that when I first entered the report by clicking on the link in the Repository, the report was being sent null values. However, when I was trying to run the report again after opening it in JasperServer, I was generating empty lists.
Matthew Dahlman suggested I create parameters in iReport to handle null values and "roll up" my grouping. Those parameters looked like:
$P{packtype}==null ? " 'All Package Types' " : " FAC.PACKTYPE_CODE "
That works beautifully in iReport and on first opening the report in JasperServer. To handle an empty list AND null values, I had to change my parameters to:
$P{packtype} == null ? " 'All Package Types' " :
($P{packtype}.isEmpty() ? " 'All Package Types' " :
" FAC.PACKTYPE_CODE ")

Dynamic Reports using SSRS

Let me declare... I am a newbie at this filling in the spot temporarily at the moment.
Problem: Develop a application summary report using SSRS 2008( the completed product should be a RDL file, which can be deployed to the SSRS Server) for the online application completed by the applicant.
A little bit of background: The applicant fills in an online application using our web application, where he completes required and optional fields. The app summary report, is provided to the applicant filling out the application as a summary of his app and should display only the fields completed by the applicant.
Example:
Lest us say John Smith lives at
Add Line 1: 123 Any Street
Add Line 2: Null
City: Some City
State: Some State
And his spouse Jane Smith lives at
Add Line 1: 321 Any other Street
Add Line 2: Apt A
City: Some City
State: Some State
So in the report, the null field (Add Line 2) should not be displayed for john but displayed for Jane. When I say not displayed, meaning, the field label should be hidden the and report should adjust the spacing to not show a skipped blank line in the report.
We have about 1000 such fields that can or cannot be answered by the applicant. So the report should be generic and use as much of inbuilt functionality as possible.
If needed, an Xml containing key value pairs of fields and responses. this Xml can be made so that it can contain all fields and unanswered responses as null or only answered responses. i am not sure how this would help but putting it out there if needed.
I have done simple reports, but i have no idea on how to approach this situation. Any help will be great help.
Thanks.
I have had a similar situation and ended up using this approach within a textbox. Taking your example above, you would have this setup for your fields within the textbox, with the [ ] being fields from the dataset:
Name: [first_name] [m_name] [last_name]
Add Line 1: [address_1]
[expression]City: [city_name]
State: [state_name]
Zip: [zip_code]
Note that the expression and the City have no space between them. What happens is the city will be on its current line when [address_2] is null and move to the next line when there is an address line 2, using this expression:
=IIF(IsNothing(Fields!address_2.Value), "",
“Add Line 2: “ & Fields!address_2.Value & VbCrLF)
When the IFF is true and [address_2] is null the expression will write “” (Nothing) and [city_name] will remain on the same line. When the IFF is false and there is an [address_2] the label “Add Line 2” will be written along with the value of [address_2] and the [city_name] will be moved to the next line by “VbCrLf”. A more robust method that handles if [address-2] has a string of length 0 or a few spaces is this expression:
=IIF(IsNothing(Fields!address_2.Value) OR Len(Trim(Fields!address_2.Value)) < 1, "",
“Add Line 2: “ & Fields!address_2.Value & VbCrLF)
This stops the strange double space when a field is empty but not null; something similar woks great for middle names. Hopefully this is helpful to you or someone else reading this post.
This was really simple...
Lets say we have a report which is in a tabular format using rectangles and textboxes,
--------------------
|FIRST NAME : AAAA |
|LAST NAME : BBBB |
|PHONE: XXX-XXX-XXXX|
--------------------
Use the following expression to control visibility of the controls that you want to hide
=IsNothing(First(Fields!WorkPhoneNumber.Value, "DataSet1"))
Make sure all the controls are of the same height and width. I created a row with just 2 controls (the label text box and the value text box) and set their visibility using the value of the value text box as described in the expression above.
Since the row had just two controls the hiding the would auto adjust the layout as i desired.

Pass values from main report to sub report?

I just started to work with iReport and got the task to do some changes to already existing reports.
Currently there's a main report with section A and B (contact details and some other info). There is a sub report C and then a subreport D. My task is to replicate A and B for every item in D. If the report has many D sections I want to have an A and B for each.
All data is in the same XML document and to get the data for section A and B I have simply
((net.sf.jasperreports.engine.data.JRXmlDataSource)$F{REPORT_DATA_SOURCE}).dataSource("/Header/")
and for sub report with D section
((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/Header/ProductHeader/Member")
if I drag a field from Document Structure that displays data in Section A to section D and check the expression it says
$F{ContactNumber} but displays Null in D even though it displays a value in section A
How do I need to modify my data sources to display content of A and B in D?
Thanks in advance
You need to pass parameters to your sub-report. A sub-report doesn't share any data from your main report unless you explicitly define the contract. It is more like a method call then a continuation of the main report.
If you wanted to display a field with the name foo in your main report in the sub-report you would need to do the following:
Create a parameter in your sub-report with the name foo.
Create a sub-report element in your main report.
In the Properties of the sub-report element, there is a property called "Parameters". Open up the dialog and add a parameter with the name foo and the correct value expression.
When you want to use the value for foo in your sub-report you should use the expression: $P{foo} if it is a main report parameter.