Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
What I want to do is REALLY simple.. so I must be thick as I can't get this to work!!
When I load my data I have a field [Report Date] linked to all my data, then I use calendar to create a MaxDate field.
I want to create a macro (to link to a button) to select all the [Report Date] data linked to this month, i.e. month of the MaxDate field.
All I want to say is Year(MaxDate) = Year[Report Date] and Month[MaxDate]=Month[Report Date] but am not sure of syntax to use in the macro, can anyone point me in the right direction?
Many thanks,
Phil
Phil,
Assuming your only date field is the [Report Date], and assuming the format is MM/DD/YYYY, you can use action (no need for macro) like this:
Action: select in field
Field: [Report Date]
Search string:
=num(month(max([Report Date])),'00') & '/??/' & num(year(max([Report Date]))
It will select all values in the [Report Date] which are in the same month as the max [Report Date]
Thanks Michael,
We're using v8.5 so I'm not sure if actions will do the trick
Kind Regards,
Phil
Phil,
This should work:
sub SelectDates
set rd = ActiveDocument.Fields("Report Date")
e = ActiveDocument.Evaluate("=monthstart(MaxDate)")
rd.Select ">=" & e
end sub
If there are dates later than max date in the list, it will be a little different:
sub SelectDates
set rd = ActiveDocument.Fields("Report Date")
e = ActiveDocument.Evaluate("=monthstart(MaxDate)")
l = ActiveDocument.Evaluate("=monthend(MaxDate)")
rd.Select ">=" & e & "<=" & l
end sub
(Hope I didn't miss much...)