Printing a selected record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mci
    New Member
    • Jan 2007
    • 4

    #1

    Printing a selected record

    Hi!

    How can I print the selected record? I'm using visual basic 6. After I search the record, it display in the form but when I click the print button all the records will print. What I want is to print the selected record only.

    Thanks!
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Originally posted by mci
    Hi!

    How can I print the selected record? I'm using visual basic 6. After I search the record, it display in the form but when I click the print button all the records will print. What I want is to print the selected record only.

    Thanks!
    Hi there,

    Show us the code you included in the button click event, it's much easier you debug your code in that way, Good luck & Take care.

    Comment

    • mci
      New Member
      • Jan 2007
      • 4

      #3
      This are the code for search button:
      Private Sub cmdSearch_Click ()
      If OptWell.Value = True Then

      Form1.Data1.Rec ordset.FindFirs t "'" & TxtSearch.Text & "' = well"
      End If
      If OptJob.Value = True Then
      Form1.Data1.Rec ordset.FindFirs t "'" & TxtSearch.Text & "' = job"
      End If
      Unload Me
      Form1.Show
      End Sub


      and this are for the print button:
      Private Sub CmdPrint_Click( )
      DataReport1.Sho w
      End Sub

      the search and print command are working but I want to print only the selected record.
      Thanks for your immediate response!

      Comment

      • mci
        New Member
        • Jan 2007
        • 4

        #4
        I think I should create a program for the data report but I don't know what should I put on. pls help!!!

        Comment

        • desertsolider
          New Member
          • Jan 2007
          • 18

          #5
          i think u jst need to use something like crystal report to do this

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by desertsolider
            i think u jst need to use something like crystal report to do this
            Can't you just apply a filter to the datareport? (I'm not familiar with datareports, so can't say for sure.)

            Comment

            • damdam
              New Member
              • Jan 2007
              • 1

              #7
              see the code below it will help you...
              your datareport must set it source to the data environment that has a variable(text1. text) which will match and filter the record to be displayed in your datareport



              If DataEnvironment 3.rspayreg.Stat e Then DataEnvironment 3.rspayreg.Clos e
              DataEnvironment 3.payreg (Text1.Text)
              DataReport3.Sho w

              Comment

              • mci
                New Member
                • Jan 2007
                • 4

                #8
                Hi,

                damdam, it works on my program. But I had a new problem.
                I’m using VB form to add a record. After saving it, I used the datacombo to search for the newly recorded data and I can print also but if you add another record it doesn’t display in the datacombo. In order to see the newly added record I should close the program and run again.

                Meaning it shows the saved record and can print it after compiling/running the program. I used data controller to store data and this are the code:

                Private Sub CmdSave_Click()
                MsgBox "Record Saved!"
                Data1.Recordset .ADDNEW
                Data1.Recordset .UPDATE
                End Sub



                For the datacombo (this are the code came from Deke):

                Private Sub DataCombo1_Chan ge()
                If DataEnvironment 1.rsCommand1.St ate Then DataEnvironment 1.rsCommand1.Cl ose
                DataEnvironment 1.Command1 DataCombo1.Boun dText

                DataCombo1.Refr esh
                Command1.Enable d = True
                End Sub

                Thanks,
                mci

                Comment

                • Norilyn
                  New Member
                  • Mar 2007
                  • 1

                  #9
                  Hi!

                  How can I print the selected record? I'm using visual basic 6. After I search the record, it display in the form but when I click the print button all the records will print. What I want is to print the selected record only.

                  Thanks!

                  Comment

                  Working...