Weekday()

M

Maracay

Hi Guys,

I have 2 fields Date and day of the week, what I want is to move the day of
the week automatically went I input the date. I know I need to use this
function Weekday([dReportDate]), but I don’t know where to used.

Any help will be appreciated

PS: I am new at access programming
 
D

Dale Fye

Generally, it is considered poor database design to store a field that can be
computed readily from another field or combination of fields. Generally, if
you need that value in a report or form, you would write a query that
includes a computed column and uses the Weekday function in the query.

If you want to display the weekday in a form, add an unbound textbox, and
set its controlsource to: = IIF(ISNULL([dReportDate]), "",
Weekday([dReportDate]))

When you go to a new record, this will show a blank in the textbox, but if
you go to a record that has a value in dReportDate, it will show up with the
weekday in the textbox.


--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
M

Maracay

You are right, but I should give you the whole picture, I have a main form
with the dReportDate field and a subform with working shifts and depending on
the day of the week there are different shifts in the company usually is more
that one shift, in the subform (Master table of shifts) I have the number of
the day of the week for the shift and I want to link the form and subform by
this field (number of the day in the week) but in the main form I only have
the date but to link them I need the Field day of the week in the table of
the main form, how can I solve this problem?

Thanks

Dale Fye said:
Generally, it is considered poor database design to store a field that can be
computed readily from another field or combination of fields. Generally, if
you need that value in a report or form, you would write a query that
includes a computed column and uses the Weekday function in the query.

If you want to display the weekday in a form, add an unbound textbox, and
set its controlsource to: = IIF(ISNULL([dReportDate]), "",
Weekday([dReportDate]))

When you go to a new record, this will show a blank in the textbox, but if
you go to a record that has a value in dReportDate, it will show up with the
weekday in the textbox.


--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



Maracay said:
Hi Guys,

I have 2 fields Date and day of the week, what I want is to move the day of
the week automatically went I input the date. I know I need to use this
function Weekday([dReportDate]), but I don’t know where to used.

Any help will be appreciated

PS: I am new at access programming
 
D

Dale Fye

Are you going to be entering data into the MasterShifts subform, or are you
just using that to display information, and maybe as the source for another
table. If just for informational purposes, then you don't really need to
have the parent/child relationship between the main and subform. You could
do it by modifying the SQL for the subform, so that it looks for the value in
txtWeekday textbox on the main form.

So the SQL for the subform might look like:

SELECT * FROM MasterShifts
WHERE MasterShifts.DayOfWeek = Forms!frm_MainForm.txtWeekday

Then, when the user changes the value in dReportDate (I would use the
AfterUpdate) event, you would issue a command to requery the subform.

Private sub dReportDate_AfterUpdate

me.sub_MasterShifts.form.requery

end sub

If you are actually going to enter data into the subform, and it contains a
DayOrWeek field, then you could use the BeforeUpdate event of the form to
insert the value of txtWeekDay from the main form into the appropriate field
in the subform.
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



Maracay said:
You are right, but I should give you the whole picture, I have a main form
with the dReportDate field and a subform with working shifts and depending on
the day of the week there are different shifts in the company usually is more
that one shift, in the subform (Master table of shifts) I have the number of
the day of the week for the shift and I want to link the form and subform by
this field (number of the day in the week) but in the main form I only have
the date but to link them I need the Field day of the week in the table of
the main form, how can I solve this problem?

Thanks

Dale Fye said:
Generally, it is considered poor database design to store a field that can be
computed readily from another field or combination of fields. Generally, if
you need that value in a report or form, you would write a query that
includes a computed column and uses the Weekday function in the query.

If you want to display the weekday in a form, add an unbound textbox, and
set its controlsource to: = IIF(ISNULL([dReportDate]), "",
Weekday([dReportDate]))

When you go to a new record, this will show a blank in the textbox, but if
you go to a record that has a value in dReportDate, it will show up with the
weekday in the textbox.


--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



Maracay said:
Hi Guys,

I have 2 fields Date and day of the week, what I want is to move the day of
the week automatically went I input the date. I know I need to use this
function Weekday([dReportDate]), but I don’t know where to used.

Any help will be appreciated

PS: I am new at access programming
 

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