Click here to Skip to main content
15,918,109 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Pop ups Pin
ii_noname_ii17-Aug-06 2:45
ii_noname_ii17-Aug-06 2:45 
GeneralRe: Pop ups Pin
Guffa17-Aug-06 2:49
Guffa17-Aug-06 2:49 
GeneralRe: Pop ups Pin
ii_noname_ii17-Aug-06 3:20
ii_noname_ii17-Aug-06 3:20 
AnswerRe: Pop ups Pin
Guffa17-Aug-06 4:06
Guffa17-Aug-06 4:06 
Questioncrystal report Pin
eatwork16-Aug-06 10:18
eatwork16-Aug-06 10:18 
AnswerRe: crystal report Pin
Dave Sexton16-Aug-06 21:06
Dave Sexton16-Aug-06 21:06 
GeneralRe: crystal report Pin
eatwork17-Aug-06 4:26
eatwork17-Aug-06 4:26 
GeneralRe: crystal report [modified] Pin
Dave Sexton17-Aug-06 21:52
Dave Sexton17-Aug-06 21:52 
Ok, I did up a small sample app to demonstrate how to get this right. Here's how I did it.


I started off by creating a form with 3 textboxes to input data to the dataset (I chose "Name", "Product" & "Quantity" as fields for the dataset), and 2 buttons for "Add to dataset" & "View report".

I created the dataset (called dsQuote) and declared it at modular level in Form1 (Friend ds1 As New dsQuote)

I created a second form and added a Crystal Report Viewer to it (called "crv")

I added a new Crystal Report to the solution and used the Report Expert wizard to select the dataset i created earlier.

I set the solution start up object to call Sub Main().

Then I just tied it all together with a bit of code - have a look at the code below.


SubMain
Module modMain

    Public WithEvents frm1 As Form1
    Public WithEvents frmR As frmReport

    Sub Main()
        frm1 = New Form1
        Application.Run(frm1)
    End Sub
End Module


Code on Form1
Friend ds1 As New dsQuote

   Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

       Dim dr As DataRow = ds1.tblQuote.NewRow

       'add info to dataset
       dr.Item("name") = txtName.Text
       dr.Item("product") = txtProduct.Text
       dr.Item("quantity") = txtQuantity.Text

       ds1.tblQuote.Rows.Add(dr)

       'clear the textboxes
       txtQuantity.Clear()
       txtProduct.Clear()
       With txtName
           .Clear()
           .Focus()
       End With

   End Sub

   Private Sub btnReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReport.Click
       frmR = New frmReport
       frmR.Show()
   End Sub


Code on Form2
Public rptQ As Quote

  Private Sub frmReport_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

      rptQ = New Quote
      rptQ.SetDataSource(frm1.ds1)
      Me.crv.ReportSource = rptQ

  End Sub



That should solve it for you. Smile | :)

EDIT: Sorry for the crappy naming conventions, I was in a bit of a hurry. Smile | :)


-- modified at 3:59 Friday 18th August, 2006
GeneralRe: crystal report Pin
eatwork18-Aug-06 5:12
eatwork18-Aug-06 5:12 
GeneralRe: crystal report Pin
eatwork18-Aug-06 12:30
eatwork18-Aug-06 12:30 
QuestionSending text to a text box without clicking a button. Pin
KB_8bar16-Aug-06 8:45
KB_8bar16-Aug-06 8:45 
AnswerRe: Sending text to a text box without clicking a button. Pin
Stephen McGuire16-Aug-06 9:48
Stephen McGuire16-Aug-06 9:48 
QuestionHow to save any file in registy Pin
Syed Ali Raza16-Aug-06 7:21
Syed Ali Raza16-Aug-06 7:21 
AnswerRe: How to save any file in registy Pin
Christian Graus16-Aug-06 12:30
protectorChristian Graus16-Aug-06 12:30 
GeneralRe: How to save any file in registy Pin
hannesHTG17-Aug-06 3:48
hannesHTG17-Aug-06 3:48 
Questionwebclient on multiple threads? Pin
cstrader23216-Aug-06 5:12
cstrader23216-Aug-06 5:12 
AnswerRe: webclient on multiple threads? Pin
Stephen McGuire16-Aug-06 5:56
Stephen McGuire16-Aug-06 5:56 
GeneralRe: webclient on multiple threads? Pin
cstrader23216-Aug-06 6:31
cstrader23216-Aug-06 6:31 
GeneralRe: webclient on multiple threads? Pin
Stephen McGuire16-Aug-06 6:49
Stephen McGuire16-Aug-06 6:49 
GeneralRe: webclient on multiple threads? Pin
cstrader23216-Aug-06 17:23
cstrader23216-Aug-06 17:23 
GeneralRe: webclient on multiple threads? Pin
Stephen McGuire17-Aug-06 0:48
Stephen McGuire17-Aug-06 0:48 
GeneralRe: webclient on multiple threads? Pin
Keith Malwitz17-Aug-06 18:01
Keith Malwitz17-Aug-06 18:01 
GeneralRe: webclient on multiple threads? Pin
cstrader23218-Aug-06 3:12
cstrader23218-Aug-06 3:12 
QuestionUpdate database in designer Pin
cstrader23216-Aug-06 5:11
cstrader23216-Aug-06 5:11 
AnswerRe: Update database in designer Pin
Stephen McGuire16-Aug-06 5:47
Stephen McGuire16-Aug-06 5:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.