DataReport is reported in VB6

zhaozj2021-02-12  134

I am not a VB skilled worker, I have just finished using VB, in which the control section has not charged too much discount. I have been looking for a long time on the Internet, I didn't find a detailed introduction of VB6 DataReport, so I want to learn from the experience of "seniors", use CrystalReport or Excel, I don't have it, so I decided to go back to "" DataReport, don't say I really have a harvest, let's take a brief introduction to my experience, I hope to help everyone.

First introduce several common properties of the DataReport object. First, DataSource is used to set a data source. By this data source, the data user is bound to a database; the other is DataMember, set a specific data member from several data provided by DataSource; three is Leftmargin, Rightmargin, TopMargin, Bottommargin, etc., is used to specify the left and right pages of the report; fourth is Sections, the DataReport report header, page headers, details, page footnotes, and report footnotes 5 areas, if they add packets ( There can be multiple layers), then add a pair of regions, that is, group headers, packet footnotes. Where Datasource is generally a data environment or a variable of the AdoDb.connection type, while DataMember, the number of variables in the data environment or the AdoDb.Recordset type, recommended to use the data environment and Command, the page borders are definitely clear, below I mainly introduce the following Sections, which is also the essence of DataReport.

Sections is a collection that you can specify a name for each section or use its default index, from top to bottom to 1, 2 .... Each section has Height and Visible properties, you can make a section inseparable in certain conditions. A variety of report controls can be placed in the section, where rptlabel, rptimage, rptshape and rptline can be placed in any section, used to output various text, graphics, and table lines; RPTTextbox can only be placed in detail, generally used for tie The data field provided by the DataMemeber; RPTFunction can only be placed in a packet foot, which is used to output the total, maximum, minimum, average value, count, and the like using various built-in functions. The common public attributes commonly used in the above report controls have TOP, Left, Height, Width and Control Visibility with TOP, LEFT, HEIGHT, WIDTH, and the RPTTextBox also has DataField, DataMember, DataFormat, and FONT properties; other properties are no longer said.

Then introduce my experience. First, the report control you want is naming according to the type; the second is to use the RPTShape's rectangular box to make a form line box, which is much more expensive than using the RPTline box. Only the slash uses rPTLINE; three is the report title and report The head text, date and page use RPTLabel, where the capens property supports the escape character,% D is a long format date,% D is a short format date,% P is the total number of pages,% P is the current page number; Reports are placed directly in the design window. For the report, you should first consider the biggest state of the report, you can place enough controls in different regions, the location size does not have to be more important, then use VBA code before the report output. The properties of the control are adjusted, including location, height, width, font, alignment, display format, seeability, etc., corresponding to Section should also adjust its height and visibility depending on the situation. Finally, use an instance template to explain its use. Connect to the database

With data environment .rscommand name if .State = adservationen damclose.source = SQL statement. Open the desired output database data item to output End withwith report name .DataSource = data environment .DataMeMber = Command name two lines can also be fixed Set it without having to set the settings page table header section (RPTTLabel ... for the report control name) .Sections (2) .controls ("rptlabelpage"). CAPTION = "Total% P page No.% P Page" .SEctions (2) .Controls ("rptlabeldate"). CAPTION = "Print date:% D" .SEctions (3) .controls ("rptlabel1"). Left = ... Settings Detail (RPTShapex, RPTTextBoxXX) .SEctions (3 ) .Controls ("rptshape1"). Left = ... .SEctions (3) .controls ("rptshape1"). TOP = ... .SEctions (3) .controls ("rptshape1"). Height = ... .sections (3). Controls ("rptshape1"). Width = ... .SEctions (3) .controls ("rpttextbox1"). DataMber = Command name .sections (3) .controls ("rpttextbox1"). Datafield = field 1.sections (3). Controls ("RPTTEXTBOX1"). Font.name = ... .sections (3) .controls ("rptshapen"). Visible = false .sections (3) .controls ("rpttextboxn"). Visible = false .... Sections (3 ) .Height = Calved or fixed detail height dynamic adjustment report title (rptlabeltitle is the report label control name) .SEctions (2). Controls ("rptlabeltitle"). Left = ... .sections (2). Controls (" RPTLabelTitle "). Alignment = ... ... After adjusting. SHOW or .Printreporte

转载请注明原文地址:https://www.9cbs.com/read-7493.html

New Post(0)