Showing posts with label vba. Show all posts
Showing posts with label vba. Show all posts

Monday, March 19, 2012

Change Crystal Database in vba

hi,

I have to use vba to display a report.
But this report should work on multiple database without having to change the report each time.
So I would like to change the report on runtime.
I think i can use LogOnServer (method of the application Object) or something.

Now i don't know how to use it. Looked for examples on the kb of crystal and this forum but wasn't succesfull to make it work.

Can somebody help me.

This is the code i use to call the report:

Set crxReport = crxApplication.OpenReport(MyReportFile)

crxReport.ParameterFields(1).AddCurrentValue (DocNumber)

Me!Crviewer1.ReportSource = crxReport

Me!Crviewer1.ViewReport

Crviewer1.Zoom (100)

While Me!Crviewer1.IsBusy
DoEvents
Wendreport.Database.Tables(1).SetLogOnInfo ServerName, DBName, UserID, Pwd

This will set the logon info for the table used in the report.

Friday, February 24, 2012

Cellset.open hangs, query works fine in Management Studio?

Hi All,

We are experiencing a very strange Cellset behaviour.

Trying to open a cellset in VBA (same in VB6) in Excel 2003, using ADOMD.Catalog, accessing a AS2005SP2, the system 'sometimes' hangs, depending on the 'dynamic' MDX query string. While the query works fine in the SQL Management Studio.

For example, this MDX works fine:

select descendants {[Measures].[NumberOfA]} on columns, [Time].[Month].[200502] on rows

from [DWH]
where {([Client].[Hierarchy].[Group].&[G000879])}

This one causes Excel (and VB6) to freeze, but nicely returns a result in SQL Management Studio!!!?

select descendants {[Measures].[NumberOfA]} on columns, [Time].[Month].[200501] on rows

from [DWH]
where {([Client].[Hierarchy].[Group].&[G000879])}

There is nothing wrong with the data, it's more connection related (I expect...)?

Does somebody have any advice?

PS: we have msxml6,asoledb9 installed

It is a firewall issue. See also: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1558402&SiteID=1

Cheers,

Tom

Cell Formatting

Hi,

On importing an XML file using VBA I/O function, I need to apply rules/format to specific Excel 2003 .Cells.

XML
<Column FieldName="ProductReference" FieldNumber="1">
<DataType>character</DataType>
<Format>x(20)</Format>
<Restrictions/>
<Mandatory>true</Mandatory>
<PermittedValues/>
</Column>

If the above XML-lines (strings) are read, I need to apply the following rules/formats to the identified .Cells(x,1):

1.
.Columns("A").NumberFormat = "General" or "Text" ??
2.
That when inputting a value, the user is restricted to 20 Characters
3.
That this is a Mandatory entry field

These values obviously change as per XML Output. Can anyone help, please?Is this related to Crystal Reports?