How to use a dynamic parameter with a command in crystal reports? - dynamic

The problem I'm running into is quite easy to recreate.
In Crystal Reports Developer I add two different tables:
The full table "Users"
A Command containing SELECT * FROM Users
In the Field Explorer I add a new parameter and set this to dynamic. I have this parameter pull it's data from any field in either of the two tables (doesn't matter). Of course making sure the parameter is used in the record select.
If I now preview this report (in Developer) it works perfectly. I get a popup allowing me to select data from whatever field I selected in the parameter.
Using this report in Crystal Viewer it prompts for database username and password.
It seems it only does this when the same report contains both a dynamic parameter and a command. Removing the SQL command (leaving only the table) and the report works as expected.
Does anyone know how to resolve this, or is there some workaround?

Related

Passing multiple parameter values to crystal reports using SQL

I have in my report a few needed arguments like 'A','B','C' and I would like to pass it using SQL.
How can I do that?
I tried prm_szDiscType='C','N','P' , prm_szDiscType = C,N,P, and prm_szDiscType=''C'',''N'',''P''
I'm not sure how you pass parameters via URL.
In Crystal Reports desktop client, I created a Command Parameter with "Allow multiple values" check on.
Then in my Command SQL, I use a where clause such as:
where item in {?Item}
When you check "Allows multiple values" on, Crystal will create the clause after in. If you select Value Type of String, the values you enter will automatically be wrapped in single quotes.
Credit to ExpertsExchange thread on command parameters ;)

Allow Drop Downs in an SSRS Report (2008) to accept text as an input

Okay, so I have an SSRS report that has a parameter with available values from a query. All of this works fine, but I would like the user to be able to select multiple items using: "SomeText%" which will retrieve all like: SomeText12, SomeTextHeyThere etc. The sql for this is all set up, but once you set the parameter to get values from a query in visual studio, you don't have the option to enter in text as well. This seems like it should be a common feature. Does anyone know how to add it so that the user can enter text and select from the drop down at the same time? I can create 2 parameters to do this, but that is just clunky.
Thanks!

(VB / ACCESS / CR) Filter VB Crystal Report based on Access Form

Before I get to the question, here is an overview of what is going on.
Access
A form that has a ComboBox that selects a JobId
Crystal Reports
A Report that calls info from several tables, all based on the JobID
VB
A Form (Using the Crystal Reports Plug-In) that shows the Report outside of the Crystal Reports Designer app.
My Problem
I need the report displayed in VB to be filtered to the job chosen in the Access ComboBox.
Update
I have my Database linked to VS2012, and that works fine without any issues. I can pull info from a Table easily. What I need to do is link the ComboBox from an Access Form to VS2012 to filter the Report.
I hope that makes my question clearer.
Update 2
I was able to figure out how to create a SELECT Query based on the value of my ComboBox inside of Access, so I should be able to use that to access the Value I am looking for, however I still need to know how to use that value as a filter for CR...
One possible solution would be to create a saved Select Query in Access that replicates the query in CR, and name that query [JobReport_base]. Then, create another saved Select Query in Access and name it [JobReport_current]. Add some code to your Access form that updates the .SQL property of the [JobReport_current] query to return just the records for the selected [JobId], something like
Dim qdf As DAO.QueryDef
Set qdf = CurrentDb.QueryDefs("JobReport_current")
qdf.SQL = "SELECT * FROM JobReport_base WHERE JobId = " & cbxJobId
Set qdf = Nothing
Then update your Crystal Report to pull the data from the [JobReport_current] query instead of the individual tables.
Multiple solutions. In your case, the simplest ones are the following:
There is this 'sqlQueryString' property of the report that you could update by directly updating the string.
You could also add a parameter (let's call it 'PAR_yourCombobox') to the report. When accessing the report in your VB code, just set the value of your parameter to the value on the screen. as far as I remember, it should look like:
yourReport.parameterFields(i).addCurrentValue yourForm.controls("yourCombobox").value

Access Form Textbox as Input query to ODBC source returns empty dataset

I have an Access 2010 utility that is designed to query an Oracle DB via ODBC connection as Linked Tables. I created a simple form with two textbox's and a command button. The command button launches VBA code "DoCmd.OpenReport".
The report query Where clause looks like this:
WHERE (((PRODLAW_ITEMLOC.LOCATION)=[Forms]![frm_Qry_ByItem&Loc]![txtLocation]) AND ((PRODLAW_ITEMMAST.ITEM)=[Forms]![frm_Qry_ByItem&Loc]![txtItem]));
the values of txtItem and txtLocation are the user supplied values from the form.
This returns an empty dataset as it is now. If I query a local table, (using a single ODBC query to extract all possible values into a single local table) this method works without any issue other than the 8-10 minutes it takes to refresh the local table. If I replace the query criteria "[Forms]![frm_Qry_ByItem&Loc]![txtItem]" with a simple direct value like "1234" (assuming 1234 is a valid item number), it works without issue.
I've tried to explicitly convert the value of the textbox like "Cstr([Forms]![frm_Qry_ByItem&Loc]![txtItem])" but it made no difference. As this is a query, I can't simply create a breakpoint and examine the properties of the variables so I'm left scratching my head. I've spent hours searching SO and other sites for clues but found nothing related.
Please advise. Thanks!
mfc

"Operand data type nvarchar is invalid for minus operator" in SSRS query designer/refresh fields

I have a valid query (tested in SSMS and also running fine in report Preview) however it will not update the dataset with the fields.
How can I force it to do so without manually entering all the fields?
Currently, if I click "Refresh Fields" I get the above error returned
Although the report/dataset parameters were correctly defined, in order to get the fields returned, you have to hard code a bunch of
DECLARE #BILLGATES VARCHAR(100) = 'BEL-LEND'
statements at the top of the query, then remove them once you've refreshed the fields
(this is within the query windows in the dataset definition, also poor is the fact that once you click 'refresh fields' there is no visual indication of any means to indicate success/failure/anything)