Wednesday, March 28, 2012
Max length for an if statement
Here is an example of what I am using.
*******************************
If (InStr({Concurrence.ConcurrenceName}, " MD", 1) > 0 _
or InStr({Concurrence.ConcurrenceName}, " COS ", 1) > 0 _
or InStr({Concurrence.ConcurrenceName}, ", M.D.", 1) > 0 _
or InStr({Concurrence.ConcurrenceName}, "M.D.", 1) > 0 _
or InStr({Concurrence.ConcurrenceName}, " M D", 1) > 0 _
or InStr({Concurrence.ConcurrenceName}, "D.O.", 1) > 0 _
or InStr({Concurrence.ConcurrenceName}, " DO", 1) > 0 _
or Instr({Concurrence.ConcurrenceName}, " DR.", 1) > 0 _
or Instr({Concurrence.ConcurrenceName}, " DR ", 1) > 0) _
or InStr({Concurrence.ConcurrenceName}, "MD", 1) > 0 _
or InStr({Concurrence.ConcurrenceName}, " DO ", 1) > 0 _
or InStr({Concurrence.ConcurrenceName}, "DR", 1) = 1) then
formula = "Physician"
ElseIf (InStr({Concurrence.ConcurrenceTitle}, "PHYSICIAN", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "ATTENDING", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "ACOS", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "COS ", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "CHIEF MEDICAL", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "CHIEF OF STAFF", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, " M.D.", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, " MD,", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "MD", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "M.D", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "D.O.", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "SURGEON", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "INTERNIST", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "DOCTOR", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, " CHIEFOFSTAFF", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "ANESTHESIOLOGIST", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "CARDIOLOGIST", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "CHIEFSOFSTAFF", 1) > 0 _
or InStr({Concurrence.ConcurrenceTitle}, "AOD", 1) > 0) then
formula = "Physician"
End If
For some reason crystal does not pull out the "PHYSICIAN" title in the second if else statement. However, if I put it in its own if statement it will evaluate properly. (I broke the if statement up for maintenance ease)
Like this:
If InStr({Concurrence.ConcurrenceTitle}, "PHYSICIAN", 1) > 0 Then
formula = "Physician"
End If
So, I am wondering if I simply have too long of an if statement and need to break this up in order to get all of the titles I am looking for.
Any suggestions on how long each if statement can be, or possibly a more efficient way to write this?
Thanks in advance.
RyanIf there are many IFs then why cant you use Case statement?sql
Max Height problem!
I have written a VB .Net application over 33 webforms which act as a "Wizard" interface by collecting data from a user on each screen - I have one backend SQL server 2000 table for each form.
When the user reaches the last form they have a "Print button" which when clicked creates a localreport, creates a dataset of all data across all tables, creates a reportdatasource based on the dataset.
It then reads a local rdlc file and performs various formatting options by dynamically changing the XML.
I then call LoadReportDefinition to load the report.
I then render the report as a PDF to a byte array and write the array to the response object:-
'Populate(Dataset)
thisdataSet = SqlHelper.ExecuteDataset(sqlConn, "spReportData", FormID)
'Create ReportDataSource
datasource = New ReportDataSource("Accountform_spReportData", thisdataSet.Tables(0))
rpt.LoadReportDefinition(GetCustomizedReportDefinition(thisdataSet, "c:\accountform\Accountformdata.rdlc"))
rpt.DataSources.Clear()
rpt.DataSources.Add(datasource)
rpt.Refresh()
bytes = rpt.Render("PDF", Nothing, mimeType, encoding, extension, streamids, warnings)
' ''Sent byte array to client
Response.Clear()
Response.ContentType = mimeType
Response.AddHeader("content-disposition", "attachment; filename=New Account Form.pdf")
Response.BinaryWrite(bytes)
Response.End()
Everything has been working a treat until I realised that the the report body appears to be limited to 160 inches in height. My report only ever has 1 very wide record in it and is a series of rectangles containing textboxes each rectange is set to have a page break after it. Given that each rectange is 27cm in height it appears that the maximum number of pages I will be able to render is 15 - I need it to be able to go up to 33.
Is there any way of combining 2 reports in to one when you call the render method?
Any other suggestions will be greatly appreciated.
That's an odd limitation. You may want to look at exporting two PDF files and then using a tool like abcPDF to join them.
Here's another article using itextsharp.
http://geekswithblogs.net/bsherwin/archive/2007/06/29/113566.aspx
cheers,
Andrew