Connecting Tech Pros Worldwide Forums | Help | Site Map

Data Reports

Ali Rizwan's Avatar
Banned
 
Join Date: Aug 2007
Location: Lahore Pakistan
Posts: 929
#1: Nov 2 '07
Hi all,

How can i add or delete some columns from datareport at runtime.
How can i refresh datareport at runtime.

How can i format fields at runtime
How can i cjange the datastring or database at runtime.

Using XP
Using VB6
Using Data Environment
Using Data Report not Crystal Reports.

Thanx

Dököll's Avatar
Moderator
 
Join Date: Nov 2006
Location: Upstate NY - US
Posts: 2,268
#2: Nov 3 '07

re: Data Reports


Quote:

Originally Posted by Ali Rizwan

Hi all,

How can i add or delete some columns from datareport at runtime.
How can i refresh datareport at runtime.

How can i format fields at runtime
How can i cjange the datastring or database at runtime.

Using XP
Using VB6
Using Data Environment
Using Data Report not Crystal Reports.

Thanx

Let's try it one at a time, if you do not mind, Ali...

I think this will handle refreshing the data:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Load()
  3.     Set conn = New ADODB.Connection
  4.     conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  5.         "Data Source=" & App.Path & "\YourDB.mdb;" & _
  6.         "Persist Security Info=False"
  7. End Sub
  8.  
  9. Private Sub cmdLoad_Click()
  10.     Set rs = conn.Execute("SELECT Field1, Field2, Field3 " & _
  11.         "Field4 FROM ThisTable ORDER BY Field1")
  12.  
  13.     Set rptTitles.DataSource = rs
  14.     rptTitles.Show vbModal
  15. End Sub
  16.  
  17. Private Sub Form_Unload(Cancel As Integer)
  18.     conn.Close
  19. End Sub
  20.  
  21.  
Tell us how that works then we'll tackle the rest. How's that for a deal?

Dököll
Ali Rizwan's Avatar
Banned
 
Join Date: Aug 2007
Location: Lahore Pakistan
Posts: 929
#3: Nov 3 '07

re: Data Reports


Thanks for the reply dokol.
But as i mention i am using dataenvironment for this purpose.
I don't want to make a connection programatically.
I just want to refresh the dataenvironment.
How can i do it.
Ali Rizwan's Avatar
Banned
 
Join Date: Aug 2007
Location: Lahore Pakistan
Posts: 929
#4: Nov 3 '07

re: Data Reports


Some more questions please..
How can i mke new controls in a datareport.
Thanx
Ali Rizwan's Avatar
Banned
 
Join Date: Aug 2007
Location: Lahore Pakistan
Posts: 929
#5: Nov 3 '07

re: Data Reports


How can i make a datareport progrmaticaly.
Thanx
debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,511
#6: Nov 3 '07

re: Data Reports


Both the threads are merged for better management of the forum.
Familiar Sight
 
Join Date: Oct 2007
Posts: 158
#7: Nov 3 '07

re: Data Reports


HI

as far as my knowledge is we cannot delete control from datareport but can set their visibliltity to false. but for this type of problams i apply following logic.

draw 13 (or any number ) lables for headings and 13 Text boxes in the datareport.

set their visible property to false.

name labels as Label0, label1, label2.... and so on
similarlay name textboxes as Text0,Text1,Text2 and so on

Query to make recordset must look as :

select strStudentName as [Student Name],strFatherName as [Father Name] from Table

write following loop to bind these controls

for i = 0 to rst.fields.count-1

dataReport.sections("PH").controls("Label" & i).caption = rst.fields(i).name
dataReport.sections("PH").controls("Label" & i).visible = true

dataReport.sections("Detail").controls("Text" & i).datamember = ""
dataReport.sections("Detail").controls("Text" & i).datafield = rst.fields(i).name
dataReport.sections("Detail").controls("Text" & i).visible = true
next

dim ii
for ii = i to 13 '(Max no of controls in the data report)
dataReport.sections("Detail").controls("Text" & ii).datamember = ""
dataReport.sections("Detail").controls("Text" & ii).datafield = rst.fields(0).name
dataReport.sections("Detail").controls("Text" & ii).visible = false
next

This way you can show or hide controls at run time
i have directly typed the code in this window. so possibilit of errors exists. These lines are just to suggest the logic

regards
manpreet singh dhillon hoshiarpur
Ali Rizwan's Avatar
Banned
 
Join Date: Aug 2007
Location: Lahore Pakistan
Posts: 929
#8: Nov 3 '07

re: Data Reports


Thanks a lot.
I ll try it and tell you how it works.
Newbie
 
Join Date: Aug 2008
Posts: 1
#9: Aug 18 '08

re: Data Reports


Quote:

Originally Posted by Ali Rizwan

Thanks a lot.
I ll try it and tell you how it works.

>>>>>hii nice snippet...workin well
Reply


Similar Visual Basic 4 / 5 / 6 bytes