VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This Code Will Show us that HOW CAN ACCESS DATA ON DATAREPORTS

by Ali Farooq (2 Submissions)
Category: OLE/COM/DCOM/Active-X
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 18th May 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This Code Will Show us that "HOW CAN ACCESS DATA ON DATAREPORTS"

API Declarations


' MICROSOFT ACTIVEX DATAOBJECTS RECORSSET 2.1 LIBRARY
' From PROJECT MENU (REFRENCES)

' Create DATABASE(db1) and Table(tb1) in MS ACCESS.
' Fields of tables are ID, NAME, MARKS
' Save database (db1) in D DRIVE


' put 3 textboxes (array) and 3 labels on form.
' add one command button and name it with CmdSHOWREPORT

' add datareport and name it DataReport1
' add 3 lables and 3 RptTextBoxes in detail section of datareport
' in DATAFIELD (property of RptTextBox) write field of Tables one by one

' after doing all above steps paste following code in ur codding section
' on getting error please contact me.i will help u

' wish u good luck & take very good care of ur self

Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset


Rate This Code Will Show us that HOW CAN ACCESS DATA ON DATAREPORTS



 mystr = "select * from tb1"
    Set rs = con.Execute(mystr)
    Set DataReport1.DataSource = rs
    DataReport1.Show
End Sub

'connection with data base
Private Sub Form_Initialize()
    ''both ways of connecting r absolutely right
'    con.Provider = "microsoft.jet.oledb.4.0;data source = C:\My Documents\db1.mdb"
'    con.Open
    con.Open "provider= microsoft.jet.oledb.4.0;data source = e:\db1.mdb"
    rs.Open "tb1", con
        Form1.Caption = "loaded successfully"
End Sub

'TO SET SOURCE OF THE DATA
Private Sub Form_Load()
    For i = Text1.LBound To Text1.UBound
        Set Text1(i).DataSource = rs
    Next
End Sub

'TO SET fields of the data. FIELDS MUST BE SAME
Private Sub Form_Activate()
        Text1(0).DataField = "ID" 'name of table field
        Text1(1).DataField = "NAME" 'name of table field
        Text1(2).DataField = "MARKS" 'name of table field
End Sub



Download this snippet    Add to My Saved Code

This Code Will Show us that HOW CAN ACCESS DATA ON DATAREPORTS Comments

No comments have been posted about This Code Will Show us that HOW CAN ACCESS DATA ON DATAREPORTS. Why not be the first to post a comment about This Code Will Show us that HOW CAN ACCESS DATA ON DATAREPORTS.

Post your comment

Subject:
Message:
0/1000 characters