MacroManII
Programmer
I am using the following code to run a simple Brio Query from VB. I would like to set up and run a a Brio Query that needs to connect using a DataBase Connection File (.oce), and supply a username and password to gain access. Does anyone know how to do this ?
MacroManToo
Option Explicit
Private Sub Main()
On Error GoTo Err_Trap
Dim bqApp As BrioQry.Application
Dim bqDoc As BrioQry.Document
Dim bqSec As BrioQry.Section
Dim strDoc As String
Set bqApp = New BrioQry.Application
bqApp.Visible = False
Set bqDoc = bqApp.Documents.New("MacroManII.Bqy"
bqDoc.Sections.ImportDataFile "C:\mymail.csv", bqImportFormatCommaText
bqDoc.Sections("mymail.csv"
.Activate
With bqApp.ActiveSection
.Columns.AddComputed "DATE", "ToDate ( Substr ( DATE_STAMP, 2, 10) )"
.Columns.AddComputed "TIME", "ToDate ( Substr ( DATE_STAMP, 13, 8 ) )"
.Columns.AddComputed "MONTH", "ToChar ( DATE, ""yy - mm""
"
.Columns.AddComputed "WEEKDAY", "NextDay ( DATE, 'Monday' )"
.Columns.AddComputed "DIFF", "WEEKDAY - DATE"
.Columns.AddComputed "DAY", "Decode ( DIFF, 7 ,'Mon' ,1,'Sun',2,'Sat',3,'Fri',4,'Thu',5,'Wed', 6,'Tue' ,'Xyz' )"
End With
bqDoc.Sections.Add bqPivot, "mymail.csv"
bqDoc.Sections("Pivot"
.Activate
bqApp.ActiveSection.Name = "MyMail Pivot"
With bqApp.ActiveSection
.TopLabels.Add "ACTION"
.SideLabels.Add "MONTH"
.SideLabels.Add "DATE"
.SideLabels.Add "DAY"
.Facts.Add "BOX COUNT"
.Facts.Add "COST"
.Facts("COST"
.DataFunction = bqDataFunctionSum
.SideLabels("MONTH"
.Totals.Add
.SideLabels("DATE"
.Totals.Add
.TopLabels("ACTION"
.Totals.Add
.HTMLExportBreakRowCount = 10000
.Export "C:\costs.htm", bqExportFormatHTML, True, False
End With
bqApp.Quit
Exit_Main:
Set bqDoc = Nothing
Set bqApp = Nothing
Exit Sub
Err_Trap:
MsgBox Err.Description, vbCritical, Err.Number
Resume Exit_Main
End Sub
MacroManToo
Option Explicit
Private Sub Main()
On Error GoTo Err_Trap
Dim bqApp As BrioQry.Application
Dim bqDoc As BrioQry.Document
Dim bqSec As BrioQry.Section
Dim strDoc As String
Set bqApp = New BrioQry.Application
bqApp.Visible = False
Set bqDoc = bqApp.Documents.New("MacroManII.Bqy"
bqDoc.Sections.ImportDataFile "C:\mymail.csv", bqImportFormatCommaText
bqDoc.Sections("mymail.csv"
With bqApp.ActiveSection
.Columns.AddComputed "DATE", "ToDate ( Substr ( DATE_STAMP, 2, 10) )"
.Columns.AddComputed "TIME", "ToDate ( Substr ( DATE_STAMP, 13, 8 ) )"
.Columns.AddComputed "MONTH", "ToChar ( DATE, ""yy - mm""
.Columns.AddComputed "WEEKDAY", "NextDay ( DATE, 'Monday' )"
.Columns.AddComputed "DIFF", "WEEKDAY - DATE"
.Columns.AddComputed "DAY", "Decode ( DIFF, 7 ,'Mon' ,1,'Sun',2,'Sat',3,'Fri',4,'Thu',5,'Wed', 6,'Tue' ,'Xyz' )"
End With
bqDoc.Sections.Add bqPivot, "mymail.csv"
bqDoc.Sections("Pivot"
bqApp.ActiveSection.Name = "MyMail Pivot"
With bqApp.ActiveSection
.TopLabels.Add "ACTION"
.SideLabels.Add "MONTH"
.SideLabels.Add "DATE"
.SideLabels.Add "DAY"
.Facts.Add "BOX COUNT"
.Facts.Add "COST"
.Facts("COST"
.SideLabels("MONTH"
.SideLabels("DATE"
.TopLabels("ACTION"
.HTMLExportBreakRowCount = 10000
.Export "C:\costs.htm", bqExportFormatHTML, True, False
End With
bqApp.Quit
Exit_Main:
Set bqDoc = Nothing
Set bqApp = Nothing
Exit Sub
Err_Trap:
MsgBox Err.Description, vbCritical, Err.Number
Resume Exit_Main
End Sub