Calculate in report or Query?

S

sam

I'm using the following to show a day of the week alongside the date in a
report. I am wondering if this should be done in the report or done in the
query... maybe even a function to return the answer to the query? Any
opinions on the best way to do it?

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim DOW As String
Select Case Weekday(txtDemoDt)
Case 1
DOW = "Sun"
Case 2
DOW = "Mon"
Case 3
DOW = "Tue"
Case 4
DOW = "Wed"
Case 5
DOW = "Thu"
Case 6
DOW = "Fri"
Case 7
DOW = "Sat"
End Select
Me.txtDOW = DOW

End Sub
 
R

Rob Parker

I'd do it as a calculated field in the report's recordsource query. But I'm
open to better advice from the multitude of MVPs ;-)

Rob
 
A

Allen Browne

Instead of writing code, you could just add another text box with these
properties:
Control Source =[txtDemoDt]
Format ddd
 
S

sam

Thanks Allen. If there is a complicated or long winded way to do something I
can usually find it. Your idea looks a much better option
--
Thanks


Allen Browne said:
Instead of writing code, you could just add another text box with these
properties:
Control Source =[txtDemoDt]
Format ddd

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

sam said:
I'm using the following to show a day of the week alongside the date in a
report. I am wondering if this should be done in the report or done in the
query... maybe even a function to return the answer to the query? Any
opinions on the best way to do it?

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim DOW As String
Select Case Weekday(txtDemoDt)
Case 1
DOW = "Sun"
Case 2
DOW = "Mon"
Case 3
DOW = "Tue"
Case 4
DOW = "Wed"
Case 5
DOW = "Thu"
Case 6
DOW = "Fri"
Case 7
DOW = "Sat"
End Select
Me.txtDOW = DOW

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top