Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the Date Format in a Data Report 1

Status
Not open for further replies.

NeilFrank

Programmer
Joined
Mar 12, 2000
Messages
167
Location
CA

Although VB offers a very large number of date formats for Data Reports, I can’t seem to be able to figure out how to change a format at RUN time.

For example, if I have an RptTextBox named txtDate in the Details Section of the report, variations on the following are illegal, giving me an ‘Object doesn’t support this property or method’ error on line **

Dim intCount As Integer
With rptMe.Sections(3).Controls
For intCount = 1 To .Count
If .Item(intCount).Name = "txtDate" Then
.Item(intCount).DataFormat = "%m-%d-%Y" **
Exit For
Next intCount
End With
 
Why don't you just use the Format statement?


If .Item(intCount).Name = "txtDate" Then
.Item(intCount).Text = Format(.Item(intCount).Text , "mm-dd-yy")
Exit For
 
sorry, I don't use Data Reports that much, so I'm not sure of the significance of the % symbol in your code, but let me know if this solves your problem
 
Nice thought. RptTextBoxes don't have a Text Property; the most comparable (I guess) is their DataField Property. And it turns out that the following is legal:

Dim intCount As Integer
With rptMe.Sections(3).Controls
For intCount = 1 To .Count
If .Item(intCount).Name = "txtDate" Then
.Item(intCount).DataField = Format.Item .DataField,"%m-%d-%Y")
Exit For
Next intCount
End With

Unfortunately it doesn't work.
Keep thinking!



 
Ok, how about this? Try setting the DataField's Format property instead of the Control's DataFormat property:

.Item(intCount).DataField.Format = "%m-%d-%Y"

I got this from the help file on RptTextBox, and found that a DataField object has a Format property, so give it a shot!
 
Maybe that was it...it's not the DataField that has the Format property, it's the DataFormat object.

Try:

.Item(intCount).DataField.DataFormat.Format = "%m-%d-%Y"
 
I'm sorry, not the DataField, the TEXTBOX's DataFormat object....

So it would be

.Item(intCount).DataFormat.Format = "%m-%d-%Y"
 
Now this works beautifully! It's a sight to behold.
I never would have deduced the syntax in a sunth of Mondays. (DataFormat.Format ???????!!!!! ==> BillGates.Gates)

You just got my vote for expert tipster,LLomaxX.
Lemme know if you're having any VB problems yourself
(nfrank@cox.net)

Mucho obligato!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top