phpman
Feb 15th, 2008, 10:08 AM
I have read many threads and I still don't understand. I don't have crystal reports. I am working with the data reporting from vb6.
I have something like this
Set Cn = New ADODB.Connection
Cn.CursorLocation = adUseClient
Cn.Open "provider=MSDataShape;data provider=microsoft.jet.oledb.4.0;Data Source=" + App.Path + "\Software.mdb"
If ChkAll.Value = 1 Then
s = "Department like '%'"
area = "All Departments"
Else
s = "Department = '" & CmbDept.Text & "'"
area = CmbDept.Text
End If
If s <> "" Then
'MsgBox "SELECT UserID, [Software Title], Version, Department, [Assigned Date], Server FROM [MS Office Licenses] WHERE " & s & " ORDER BY [" & CmbOrderby1.Text & "], [" & CmbOrderby2.Text & "]"
Dim rpt As New RptBydept
rs.Open ("SHAPE{SELECT Machine, UserID, [Software Title], Version, Department," & _
"[Assigned Date], Server FROM [MS Office Licenses] WHERE " & s & " and " & _
"UserID NOT LIKE '--%' ORDER BY [" & CmbOrderby1.Text & "], [" & CmbOrderby2.Text & "]}" & _
" AS SQL1 " & _
"COMPUTE count(SQL1.Department) AS DeptCount,SQL1 BY Department"), Cn, adOpenStatic, adLockOptimistic
'Update fields and datareport control names to those you use
'Set datasource and bind recordset fields.
Set rpt.DataSource = rs
'First = False
rpt.Sections("Section1").Controls("Text8").DataField = "DeptCount"
With rpt.Sections("SQL_Detail")
.Controls("Text1").DataField = "UserID" 'where quantity is a field in the recordset
.Controls("Text1").DataMember = "SQL1"
.Controls("Text2").DataField = "Software Title"
.Controls("Text2").DataMember = "SQL1"
.Controls("Text3").DataField = "Version"
.Controls("Text3").DataMember = "SQL1"
.Controls("Text4").DataField = "Department"
.Controls("Text4").DataMember = "SQL1"
.Controls("Text5").DataField = "Server"
.Controls("Text5").DataMember = "SQL1"
.Controls("Text6").DataField = "Assigned Date"
.Controls("Text6").DataMember = "SQL1"
.Controls("Text7").DataField = "Machine"
.Controls("Text7").DataMember = "SQL1"
End With
rpt.Sections("Section1").Controls("Label17").Caption = area
rpt.Show vbModal
DoCmd.OpenReport rpt, acViewNormal
Unload rpt
Call DBDisconnect
Set rpt = Nothing
'Unload FrmReports
Exit Sub
Else
MsgBox "Empty Search String"
End If
How do I put that ina pdf file? I have installed pdfCreator for my printer.
This just errors out "DoCmd.OpenReport rpt, acViewNormal" But I think that is for msAccess instead of regular vb.
How do I take a report like that and make it export to pdf? Also how to I export to pdf with a report.dsr ?
I have something like this
Set Cn = New ADODB.Connection
Cn.CursorLocation = adUseClient
Cn.Open "provider=MSDataShape;data provider=microsoft.jet.oledb.4.0;Data Source=" + App.Path + "\Software.mdb"
If ChkAll.Value = 1 Then
s = "Department like '%'"
area = "All Departments"
Else
s = "Department = '" & CmbDept.Text & "'"
area = CmbDept.Text
End If
If s <> "" Then
'MsgBox "SELECT UserID, [Software Title], Version, Department, [Assigned Date], Server FROM [MS Office Licenses] WHERE " & s & " ORDER BY [" & CmbOrderby1.Text & "], [" & CmbOrderby2.Text & "]"
Dim rpt As New RptBydept
rs.Open ("SHAPE{SELECT Machine, UserID, [Software Title], Version, Department," & _
"[Assigned Date], Server FROM [MS Office Licenses] WHERE " & s & " and " & _
"UserID NOT LIKE '--%' ORDER BY [" & CmbOrderby1.Text & "], [" & CmbOrderby2.Text & "]}" & _
" AS SQL1 " & _
"COMPUTE count(SQL1.Department) AS DeptCount,SQL1 BY Department"), Cn, adOpenStatic, adLockOptimistic
'Update fields and datareport control names to those you use
'Set datasource and bind recordset fields.
Set rpt.DataSource = rs
'First = False
rpt.Sections("Section1").Controls("Text8").DataField = "DeptCount"
With rpt.Sections("SQL_Detail")
.Controls("Text1").DataField = "UserID" 'where quantity is a field in the recordset
.Controls("Text1").DataMember = "SQL1"
.Controls("Text2").DataField = "Software Title"
.Controls("Text2").DataMember = "SQL1"
.Controls("Text3").DataField = "Version"
.Controls("Text3").DataMember = "SQL1"
.Controls("Text4").DataField = "Department"
.Controls("Text4").DataMember = "SQL1"
.Controls("Text5").DataField = "Server"
.Controls("Text5").DataMember = "SQL1"
.Controls("Text6").DataField = "Assigned Date"
.Controls("Text6").DataMember = "SQL1"
.Controls("Text7").DataField = "Machine"
.Controls("Text7").DataMember = "SQL1"
End With
rpt.Sections("Section1").Controls("Label17").Caption = area
rpt.Show vbModal
DoCmd.OpenReport rpt, acViewNormal
Unload rpt
Call DBDisconnect
Set rpt = Nothing
'Unload FrmReports
Exit Sub
Else
MsgBox "Empty Search String"
End If
How do I put that ina pdf file? I have installed pdfCreator for my printer.
This just errors out "DoCmd.OpenReport rpt, acViewNormal" But I think that is for msAccess instead of regular vb.
How do I take a report like that and make it export to pdf? Also how to I export to pdf with a report.dsr ?