My apologies for such a simple question but after 3 days of searching I cannot find an answer. I have a VS 2012 VB.NET application and Report. I would like to have the user enter information on a windows form, for example "Client Name: [textbox1] ". I want to pass the entered value of textbox1 to a report field. I have created the report field textbox and created a parameter in the report (rdlc) as #reportparam1. Once the user completes the form he/she will press a button that brings up the report.
You have to set parameter value and pass it to your report:
Dim parReportParam1 As New ReportParameter("parReportParam1", Me.TextBox1.Text)
Me.YourReportViewer.LocalReport.SetParameters(New ReportParameter() {parReportParam1})
In your report you must set textbox value as:
=Parameters!parReportParam1.Value
Related
I created a report template which I want to open a single page report based on a specific IDENT NO. All of the fields in the report are then generated from the associated IDENT NO.
Currently, when I open the report, it will create a single page report for each ID number in the Report Data table when opened.
Instead, when the user is attempting to open the report, I want to prompt the user to enter the identification number of the specific report they are looking for so that it only opens that single individual 1 page report associated with the entered IDENT NO.
How could I achieve this filtering?
An alternative to using InputBox is to use a "parameter query" (documentation here)
Anywhere in a query criteria or report design view you may enter [IdentNoVariable] and a dialog box will appear (when the report or query is run) asking you to "Enter Parameter Value" for IdentNoVariable.
For example, if you wanted to restrict an ID # during a query (say the query that your report calls):
The dialog box seen appeared upon running the query and has the text of the variable seen in the query criteria. This same thing can be done in a report by entering [IdentNoVariable] into the part of the report where the entered value is desired.
You can display an InputBox for the user to insert the ID and then open and filter the report.
Dim id As String
id = InputBox("Enter the identification number:", "YourInputBoxTitle")
'if a value was entered, open and filter report
If Len(Trim(id)) > 0 Then
DoCmd.OpenReport "ReportName", acViewPreview, , "[IDENT NO] = " & id, acWindowNormal
End If
So I am working on a webpage that displays stored information in a form that can be edited. Basically a Requester can enter their contact information which is stored in a database and than can be called by an "editor" who will look over their information and update the request. The issue that I am having is that when I initially populate the form it is setting the value of each textbox to an input and I want to be able to get the changed input in each form to update the database.
This is the code I use to populate the form:
Dim CustomerName As TextBox = DirectCast(RadPanelBar1.FindItemByValue("RequesterInformation").FindControl("txtCustomerName"), TextBox)
CustomerName.Text() = PMPMR.CustomerName
This is the code I use to get the updated information from the form once the editor clicks the approve button:
Dim CustomerName As TextBox = DirectCast(RadPanelBar1.FindItemByValue("RequesterInformation").FindControl("txtCustomerName"), TextBox)
Information.CustomerName = CustomerName.Text
I realize this is a very small sample to show but the code for this webpage is over 800 lines. Thank you!
I have a table name logs that holds the accomplishments log of the employees in a particular organization
ID
User_ID
Logs
StartDate
StartTime
FinishedDate
FinishedTime
I want only to print based on two user inputs. The User_ID and FinishedDate. How to achieve it using Crystal Report?
This assumes you already have a report displaying data from that table (and you don't already have parameters in your report):
Create the parameters user_Id and FinishedDate in your crystal report - right click parameter fields, and add new
Click the Report menu, then "Select Expert"
Pick the field from your data base, and choose whether you want it to be equal to you parameters
You can customise the selection criteria in the formula editor
To apply these parameters from your VB application after data binding, you need to call the SetParameterValue method on the report object as follows:
report.SetParameterValue("User_Id", 1256)
report.SetParameterValue("FinishedDate", date)
Edit
You'll need to research loading data into your report in more detail. Your question was how to pass parameters to crystal from VB.net. Below is a brief run through:
' Create a report document - pointing to your .rpt file
report = new ReportClass()
report.FileName = fileName
' Assign the report object to your viewer
ReportViewer.ReportSource = report
' perform any database logon
report.SetDatabaseLogon(...credentials...)
I have a list box and its row source is "tblitems" with bellow fields.
Now I like when right click on this list box and select one option for example "new task" it opens new task form and automatically Grab the item number from a list box and fills related text box "item number" in "new task" form that is bounded to table "tbltask"
Now when I press "Apply" button it insert new record in "tbltask".
tblItems
item number (pk)
item name (text)
tbltask
task number (auto number,pk)
item number
enter image description here
Getting a value from a list box in a form is:
Me.List_Box_Name.Value
Or if you have unbound values then get it based on the column:
Me.List_Box_Name.Column(2)
or whichever column you need.
You can then populate fields with DLookup or a recordset. Then if you want this to happen when you open a new form, you may want to look into this:
Private Sub Form_Load()
'Stuff you want to happen when that form loads
End Sub
Updated
The following will print out the value each time you click it. You can use this method to trigger a new form to open, or you can have a user click a submit button afterwards.
Private Sub Test_List_Click()
Debug.Print Me.Test_List.Value
DoCmd.OpenForm "Form_Name"
End Sub
Now I'm not exactly sure the best way to add your variable to the opened form. If it were me with my limited knowledge, I would add a global or public string and have the Form_Load() check to see if that string length is greater than 0. If yes then it will populate the field.
Hope that helps
Update 2
Actually this link will help you populate a field from previous form:
MS Access - open a form taking a field value from a previous form
I'm developing a windows forms application using VB.NET. I'm currently working on DataReport (by Microsoft, not Crystal). Everything works fine when using DataSet as DataSource. But I have a question on how am I going to put data to my DataReport from a user input? Preferably when the user is on the act of printing(clicking the print button in the ReportViewer), a Form will pop-up and ask him for input. That input I'm talking about is random names of people, and we don't have to track their names so there's no reason to put it on the database.
Here's my simple setup:
MainForm.vb (Form)
MyReportViewer (ReportViewer)
MyReport.rdlc (DataReport)
InputForm (Form)
MyInputBox (TextBox)
If it is impossible to do it on the act of printing. Maybe on the MainForm_Load event or before the generation of report can do.
I've searched the net for an hour but I'm out of luck.
I've found the answer, it's called ReportParameters.
Here's how to set it:
'Get input from user...
Dim OneParameter As String = InputBox("Enter something to display on report!", "Report Parameter")
'Prepare report parameters... The `SetParameters` requires array of `ReportParameter`...
Dim ReportParameters As New List(Of ReportParameter)
'Add the user input to `ReportParameter` array...
ReportParameters.Add(New ReportParameter("OneParameter", OneParameter, True))
'Set the `ReportParameters` of the `ReportViewer`...
FormWithReportViewer.TheReportViewer.LocalReport.SetParameters(ReportParameters)
FormWithReportViewer.Show()
FormWithReportViewer.Focus()
On the DataReport(.rdlc), we have to add a ReportParameters (Menu>Report>Report Parameters). The same name (OneParameter) should be used to avoid error. We can now use the parameter in our textbox, just put =Parameters!OneParameter.Value and we're done!
Note: We have to set the report parameters before rendering the report. If we cannot avoid that, refresh the report after adding parameters so it will be updated:
FormWithReportViewer.TheReportViewer.RefreshReport