I'm working on a LOT of VBA code that generates reports from Excel.
I reckon it's a really stupid idea to use Excel and VBA to run "queries" on an worksheet so I'd like to do it in a database environment.
I successfully ported the required table and data into OpenOffice base. The problem now is that I need to run a report that takes in user input for example in a pizza database:
"Show me total use of ham on a weekly basis and consolidate that on a month by month basis."
Where "ham" would be an ingredient that the user could change for say, "pepperoni".
How do I create a report that takes user input? Do I need to do it with a subform? Can I connect a form to a report?
Thanks to drop-lists, named ranges, and advanced functions like sumproduct(), you might be able to do everything you need in Excel, possibly without any VBA (It's more powerful than most people realize). Can you give us some more examples?
Related
I have a SQL View that I'm working on that spits out some important information for my boss's boss's boss. The view includes a field called Item ID, which can be in several different formats.
Here are some examples (that may or many not be made up to protect the innocent):
ATS-LC-PLN-RT-RH-0.3125-18-3X2.125X1.5-1
012345.012345
01234567.0123
123456789012
000000.000000
000000.000002
I'd like to take the view and use it to (eventually) produce an excel spreadsheet, but I'm not confident that there's a way to format this column in a way that will work for all of these different Item ID's.
When playing around with Excel, these numbers drop their trailing zeroes and switch to scientific notation, among other shenanigans. I just need to format this column in a way that will preserve the Item ID.
If you know of a way to programmatically create an excel spreadsheet in a way that allows me to assign a format based on the data in the cell, that would work great. The problem that I'm mainly suffering from is that this spreadsheet naturally has hundreds of lines, soon to be thousands, and there's no feasible way to hand-format these lines one at a time on a daily or weekly basis.
I've got SQL-Server 2014 and Excel via Microsoft Office Standard 2013, which may offer more options.
Permit me to suggest another way of framing your issue. I don't think you really want to analyze (either manually or programmatically) each item ID and determine whether it is an integer, a decimal, or alphanumeric text. Since your item ID data varies, the only Excel formatting that will work for all of your cases is 'Text.' So my suggestion is look for a way to automate the export of your data to Excel while making sure that the formatting in Excel is set to 'Text' for all cells to contain your item ID data. As you've noticed, if you are pasting data in Excel, if the target cells are not first set to 'Text' formatting, Excel will make its own 'corrections' to each pasted value, including removal of leading and trailing zeros.
The best solution is to use SQL Server Reporting Services (SSRS). You can set the field formatting in SSRS, and then (if you choose) automate the export of your data to Excel by calling the report server by URL with &rs:Format=excel. (There is learning curve for SSRS but if you plan to continue doing things like this, it will be worth it.)
Other options
The easiest manual option is to 1) export the data to .csv format, 2) Open Excel and use the Text Import Wizard, and during Step 3 make sure to click the data column and then choose 'Text' as the data format. (You could automate this somewhat with an Excel VBA macro.)
The most complicated method involves programming using Excel VBA and ADO to automate the connection and querying of the data from your database view, and then rendering that data to a spreadsheet, using VBA to set the formatting to 'Text.'
I'm stuck on this one...
...we're using linear regression for some trending and forecasting and I'm having to query data, create a dataset, then paste into excel and apply a linest function to my data. Since the data requirements have changed daily, this has become a very cumbersome thing to whip together. I'd want SQL Server to take care of that processing as this will be an automated forecast that I do not want to touch after I hand it over to an end user. When they refresh the data, I want it to refresh the linest function.
Here's some sample data
The [JanTrend] is a logarithmic trend in Excel that takes the trend of the Jan-12, Jan-13, and Jan-14 fields and calculates.
Here's that function in Excel
=LINEST([Jan-12]:[Jan-14]^{1})
The Forecasted field is basically [Jan-14] + [JanTrend].
StockCode Jan-12 Jan-13 Jan-14 JanTrend Forecasted
300168 2 3 11 5 16
300169 1 4 3 1 4
The JanTrend field is where my linest function is located in my excel spreadsheet.
I want to convert the above function to T-SQL or in an SSRS report. How can I achieve this?
EDIT: I'm trying to calculate a logarithmic trend. I made some changes to my sample data to makes things more clear.
the linest excel function is just linear regression. it's (still) not available in sql server, but you will find a lot of examples of UDF's or queries implementing it. just google for "sqlserver udf linear regression" or refer to this previous question.
Are there any Linear Regression Function in SQL Server?
udf's are generally slow, so you might want to go with the solution in the third post in this forum. http://www.sqlservercentral.com/Forums/Topic710626-338-1.aspx
I have dozens of SSRS Reports and the corresponding stored procedures that I am slowly cleaning up and optimizing, I am finding a number of data sets that have extra fields that are not used in the actual report, they are usually the result of a SELECT * that is slowing down the SP end of things significantly in a few places.
I am wondering if there is a quicker way to see which fields from the datasets are used/unused to more efficiently clean up the stored procedures. It seems like clicking through to each <<expr>> and checking them off is a ridiculous way to go about this.
I'll tell you, I wish I knew a tool that simplifies this for you.
And I don't off the top of my head.
But for sure I know you can search the text of the rdl and find these details.
I do this often when troubleshooting problems with existing reports (or SSIS packages).
The .rdl files are human-readable xml.
You can open any one file in a text editor and search the text - even Visual Studio if you "Open File" rather than use the Report project.
Given that, of course you can write a routine in your preferred programming language that
finds the query or proc in the data source of the Report
runs it (as metadata only) to get all the columns
search for each one in the text of the rdl
you can be more specific if you use xml queries to limit
the search to more realistic targets like display box Data Sources
Sorry I don't have a more convenient answer like an existing tool.
If I remember, I may look for one because this is a big problem for "corporate coders" like us.
If I can't find one, maybe I'll write the script in .net and come back and post it :)
Yes you can ! Use the following steps
right click the rdl file and
click the View Code . This will be an XML format
CTR + F to get a search text box
Enter the name of any field in the text box.
Use the Forward Arrow icon to see the number of occurrence of the searched field name
If the text field is in the dataset and Tablixcell value, then it shows it's being used in the report
If the text field is only in the dataset and not any tablixcell value, then it's not being used in the report.
I have not to much experience in Reporting in MVC4. I'm looking for a way to generate a report, this one is not common, I mean, I need to generate a report something like this one
As you can see, contains so much static text, and gets some parameter like the name, id, date, and an array of current grades of a students in a vertical text.
I've search for that, but I only found list reports. Can you orient me which components do I need to generate this report as printable (PDF for example)?
If you think of this as a very short list with many columns, the examples you've found may work OK.
But if I were in your position, I would probably use SQL server reporting services (SSRS) to generate a PDF-report.
See http://msdn.microsoft.com/en-us/library/hh965699.aspx
Here's the general schema for my tables(incomplete)
Employees(**EMPiD**, FirstName, Lastname, cell, name)
Trainers(**TrainerName**, Specialty)
EmployeeTrainingCompleted(**EMPID,TypeTraining,** TrainerName, Score, Comments)
Training(**TypeTraining,PositionTitle**) //this one is fishy, and likely subject to change, but irrelevent to this question
Position(**PositionTitle**,Description,StartingPay)
I am working on an Access 2010 form that will allow the user to select from a combobox the "name" field of a particular employee(which is a calculated field from fname,lname) and view all of the completed training, trainer name, comments, score, etc for that EMPID.
I have completed forms that do this for a single instance of training, but I would like for there to be one form that will dynamically display an indeterminate amount of rows for each employee(because employees have completed a different amount of training courses).
I am new to Microsoft Access and I was wondering if there is an easy way to accomplish this.
Thanks for your input.
While MySQL and Oracle are useful for the database side of things, they will be of no use for the RAD side. Access is really a RAD tool that generally, but by no means always, uses a Jet/ACE database for a back-end ( https://stackoverflow.com/tags/ms-access/info ).
To get a general idea of what you can do with Access, look at the Northwind Sample database, which you will find in New --> Sample Templates --> Northwind in your Access 2010 or if you intend to work with a web deployment, http://blogs.office.com/b/microsoft-access/archive/2010/07/19/northwind-2010-web-database-is-now-available.aspx.
Calling these "databases" is misleading, in that they include a great deal more than you will find in a database. In this case, have a look at the Order Details form under Customers & Orders.
I am not sure about the 2010 version of Northwind, but the earlier versions used to come with a warning that you should disregard any code and just use them for ideas on what you can do with MS Access. For code, consider these books MS Access 2003 - Good book on learning advanced VBA.