| Chat with a LIVE Microsoft
Access Expert! |
||||
|
||||
|
#1
|
|||
|
|||
|
format to mmm-yy
This little bit of code is filling page header text boxes in a report with data from crosstab headers - its in the PageHeaderSection_Format section.
Code:
For intX = 1 To intColumnCount
Me("Head" + Format$(intX)) = rstReport(intX - 1).Name
Next intX
but....Code:
For intX = 2 To intColumnCount
Me("Head" + Format$(intX)) = Format(Me("Head" + Format$(intX)), "mmm-yy")
Next intX
I want to be able to use this for other queries where the column headings may not be dates without having to alter the code. jim |
| Sponsored Links |
|
#2
|
|||
|
|||
|
You could offcourse if its allways this way... do this:
Me("Head1" ) = rstReport(0).Name For intX = 2 To intColumnCount Me("Head" + Format$(intX)) = Format(Me("Head" + Format$(intX)), "mmm-yy") Next intX Or if you really really need to check for a date use the functions IsDate() Regards |
|
#3
|
|||
|
|||
|
Thanks - that will definately work for this instance - and is tidier than my adding another for..next loop - however I was thinking that perhaps I might have a crosstab where 1 or 2 or even all the column headers aren't dates so that's why I was thinking there must be a way to do the test...
jim |
|
#4
|
|||
|
|||
|
Yep there is... as I also posted by using the IsDate([field]) function
|
|
#5
|
|||
|
|||
|
doh ! sorry didn't see for looking - thanks for the suggestion
Now i'm going for the isdate option yet i'm struggling mixing if...thens with for...nexts. Code:
For intX = 1 To intColumnCount
If IsDate(Me("Head" + Format$(intX)) = rstReport(intX - 1).Name) Then
Me("Head" + Format$(intX)) = Format(rstReport(intX - 1).Name, "mmm-yy")
Else
Me("Head" + Format$(intX)) = rstReport(intX - 1).Name
End if
Next intX
The dates don't change format ![]() Last edited by JimmyS; 05-19-2004 at 08:00 AM.. |
|
#6
|
|||
|
|||
|
For intX = 1 To intColumnCount
If IsDate(Me("Head" + Format$(intX)) = rstReport(intX - 1).Name) Then Me("Head" + Format$(intX)) = Format(rstReport(intX - 1).Name, "mmm-yy") Else Me("Head" + Format$(intX)) = rstReport(intX - 1).Name End if Next intX Oh come on your kidding right??? What is supposed to be date??? The Head thing right??? So only isdate(headthing) If IsDate(Me("Head" + Format$(intX))) = rstReport(intX - 1).Name Then |
|
#7
|
|||
|
|||
|
cheer - the penny just dropped literally seconds before i saw your post....I was just about to post that i'd got it
and I'm a fool Thanks namliam - i'll remember to be less swift to post my problems when a little break can make things clearer Its been a long day of staring at the same few lines of code - something I do very rarely.. i wrote this and it works to test each column header for a date: Code:
For intX = 1 To intColumnCount
If IsDate(rstReport(intX - 1).Name) Then
Me("Head" + Format$(intX)) = Format(rstReport(intX - 1).Name, "mmm-yy")
Else
Me("Head" + Format$(intX)) = rstReport(intX - 1).Name
End If
Next intX
thanks again for taking the time to post. Last edited by JimmyS; 05-19-2004 at 08:21 AM.. |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|