Solved

Setting .DataFormat param in DataReport

Posted on 2000-02-24
8
495 Views
Last Modified: 2013-12-26
I am trying to set the DataFormat property for a textbox in the detail section of a DataReport and I get a runtime error 438, "Object doesn't support this property or method."

The code is as follows:

dr.Sections(3).Controls(x).DataFormat = "#,###.00" (or similar)

I am using a SQL 7.0 database bound to the DataReport through a DataEnvironment object.  I have also tried using an unbound data source with the same result.
0
Comment
Question by:jhanf
  • 4
  • 4
8 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2560862
What is the control you want to format? You can display its name to ensure you have the right one (msgbox dr.Sections(3).Controls(x).name). The DataFormat property can only be used if the field is bound!!!
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2568652
Anybody home?!?!?!
0
 

Author Comment

by:jhanf
ID: 2568862
The control is a textbox in the detail section.  I verified the name of the control, and that it is indeed bound.  Still, the same error message appears.
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2568959
You can't set it this way. You need to use the Format object.

First, add a reference to the «Microsoft Data Formatting object library».

Then add this code to your application:
Dim fmtX As StdDataFormat
Set fmtX = New StdDataFormat
fmtX.Type = fmtCustom
fmtX.Format = "#,###.00"
Set dr.Sections(3).Controls(x).DataFormat = fmtX
0
 

Author Comment

by:jhanf
ID: 2569690
Okay, that is useful information; but the error message is generated when referencing the .DataFormat property.  VB doesn't seem to care what is on the right side of the equals sign at this point.
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 100 total points
ID: 2569994
Since fmtX is an object, you have to use the «SET» operator like I have written in my last example.

I just build a very small demo and here is the code (that works well):

Private Sub Command1_Click()
Dim fmtX As StdDataFormat

    Set fmtX = New StdDataFormat
    fmtX.Type = fmtCustom
    fmtX.Format = "#,###.00"
    Set DataReport1.Sections(2).Controls(4).DataFormat = fmtX
    DataReport1.Show
End Sub
0
 

Author Comment

by:jhanf
ID: 2570110
You are correct.  Sorry I missed the <<Set>> operator.  
0
 

Author Comment

by:jhanf
ID: 2570113
emoreau - You have been very patient and I thank you.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question