473,785 Members | 2,219 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printing a selected record

4 New Member
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!
Jan 23 '07 #1
8 6046
sashi
1,754 Recognized Expert Top Contributor
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.
Jan 23 '07 #2
mci
4 New Member
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!
Jan 23 '07 #3
mci
4 New Member
I think I should create a program for the data report but I don't know what should I put on. pls help!!!
Jan 23 '07 #4
desertsolider
18 New Member
i think u jst need to use something like crystal report to do this
Jan 23 '07 #5
Killer42
8,435 Recognized Expert Expert
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.)
Jan 23 '07 #6
damdam
1 New Member
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
Jan 29 '07 #7
mci
4 New Member
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
Jan 29 '07 #8
Norilyn
1 New Member
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!
Mar 3 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
4858
by: Jody Gelowitz | last post by:
I am having a problem with printing selected pages. Actually, the problem isn't with printing selected pages as it is more to do with having blank pages print for those pages that have not been selected. For example, if I were to have 5 pages with every second page printing, I would get the following results: Page 1 = Print OK Page 2 = Blank Page 3 = Print OK Page 4 = Blank
4
4739
by: Sami | last post by:
I hope someone will tell me how to do this without having to do any VB as I know nothing in that area. I am a rank beginner in using Access. I have created a database consisting of student athletes.  I have now learned how to join two different tables in a query so that I might generate a report. Specifically, student athletes at a community college are required to graduate with an AA or AS degree.  Consequently, various steps are in...
8
12106
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
5
2624
by: John | last post by:
Hi If I have a form open, what is the code that is equivalent to using the File->Print menu with select record(s) option to print the form with the currently displayed record values? Thanks Regards
5
8522
by: martin DH | last post by:
Hello, I am using MS Access 2002-2003. I added a "Print Record" command button to a form in my database. Is there a way (via VBA or anything else) to open a print preview screen when the command button is selected instead of immediately printing the record? Thank you! Martin DH
8
1948
by: wassimdaccache | last post by:
Hello everybody The name of the form that I'm working on is 'AddProduct' I'm trying to print a selected record that I have the focus, its name is "barecode" My report name is 'barecodeprint' that contains a text box called 'barecoderepo' I need to open the report with critiria 'barecode' ='barecoderepo' I'm using this code
3
2497
by: Dave | last post by:
Hello! What's the best way to make a button print *just* the selected (displayed) record of a subform, when that subform is currently part of a larger form? Thanks!
0
2248
by: nikhilgargi | last post by:
Requirement: I need to provide printing capability in a C# desktop application that I am developing The documents that need to be printed can be in Rich Text Format (RTF) or HTML. Custom application specific headers are to be added in the print out. Problem: The System.Drawing.Printing namespace .Net provides objects and dialogs to take care of basic print tasks. But there is no native support of printing RTF and HTML formats. One would...
18
11316
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing classes, for each of the checked rows in the GridView. This works fine in the Visual Studio 2005 development environment on localhost. But, when I move the page to the web server, I get the error "Settings to access printer...
0
9646
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10346
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.