Solved

Setting .DataFormat param in DataReport

Posted on 2000-02-24
8
503 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

691 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