D
DubboPete
Hi all,
I am trying to dynamically calculate dates, to populate a field called
[DOSEDATE]
The calculations work like this.
Patients take away doses of medicine, on particular days of the [Monday to
Friday] week. The medicine doses are prepared on any day between Monday
and Friday.
1st scenario:
Clinician signs into database on Monday 12th July, and declares Wednesday
14th July as [PROCDATE]
***This is done on a form [DATEPREP] with [Text0] set to date/time, and
Text0's After Update event hides the [DATEPREP] form and opens up Patient
Records form [DUBBOLIST]***
Patient 'A' has one record, which indicates a dose of medicine is required
as a takeaway each Saturday.
Clinician opens first patient record, and sees that checkbox [SAT] is
selected. Clinician marks record for printing (checkbox) and prints 1
label on Monday 12th July. The label contains the date that the dose is
intended for, in this scenario Saturday 17 July.
Pharmacist prepares dose on Wednesday 14th July, in accordance with label
Patient 'A' attends clinic on Thursday and takes home a dose of medicine for
Saturday 17 July
2nd scenario
Clinician signs into database on Tuesday 13th July, and declares Wednesday
14th July as [PROCDATE]
Pataient 'B' has three records, one for each day that a dose of medicine is
required
Clinician opens first patient record, and sees that checkbox [SAT] is
selected. Clinician marks record for printing (checkbox)
Clinician opens second patient record, and sees that checkbox [MON] is
selected. Clinician marks record for printing (checkbox)
Clinician opens third patient record, and sees that checkbox [WED] is
selected. Clinician marks record for printing (checkbox)
Clinician then prints 3 labels on Tuesday 13th July. Each label contains
the date that the dose is intended for, 17th, 19th and 21st of July
respectively.
Pharmacist prepares doses on Friday 16th July, in accordance with labels
Patient 'B' attends clinic on Friday 16th and takes home three doses of
medicine, one for Saturday 17 July, one for Monday 19th July and one for
Wednesday 21st July.
What I need help with is code to capture the weekday part of the [PROCDATE]
and calculate the [DOSEDATE].
Only one record is allowed for any one dose. Only one dosing date checkbox
is allowed to be clicked at any one time, so there is no doubling up of
dosing dates for one record. This is because the medicine might be
different on any subsequent dose, in either type or quantity, and the
clinician and pharmacist cannot be allowed to double-dose for any one day.
So if the [PROCDATE] is Weekday=4 (Wednesday, 14 July), and the [DOSEDATE]
is Weekday=7 (Saturday 18 July), I need for the [DOSEDATE] field to be
updated dynamically. This should be done when the record is 'MARKED FOR
PRINTING' ([PRINTFLAG] checkbox value = true)
I thought this might work, but the [DOSEDATE] is not getting updated... If
someone could check the code and steer me in the right direction I'd
appreciate it... here's the code for the [PRINTFLAG] checkbox
thanks in anticipation
and for those that don't read beyond this point, thanks for your patience!!
DubboPete
=================================
Private Sub PRINTFLAG_Click()
On Error GoTo err_PRINTFLAG_Click
'MARKED FOR PRINTING
If Me.PRINTFLAG.Value = True Then
Me.PROCDATE.Value = Forms!DATEPREP![Text0]
End If
'UNMARKING PRINT FLAG
If Me.PRINTFLAG.Value = False Then
Me.PROCDATE.Value = ""
Me.[DOSE DATE].Value = ""
End If
If Me.PRINTFLAG.Value = True Then
'MONDAY
If Forms![DATEPREP]!Text0 = Weekday(Date + 1) Then
If Me.THU.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 3
End If
If Me.FRI.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 4
End If
If Me.SAT.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 5
End If
If Me.SUN.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 6
End If
If Me.MON.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 7
End If
If Me.TUE.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 8
End If
If Me.WED.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 9
End If
If Me.PRINTFLAG.Value = False Then
Me.PROCDATE.Value = ""
End If
End If
'TUESDAY
If Weekday(Date) = 3 Then
If Me.THU.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 2
End If
If Me.FRI.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 3
End If
If Me.SAT.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 4
End If
If Me.SUN.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 5
End If
If Me.MON.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 6
End If
If Me.TUE.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 7
End If
If Me.WED.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 8
End If
If Me.PRINTFLAG.Value = False Then
Me.PROCDATE.Value = ""
End If
End If
'WEDNESDAY
If Weekday(Date) = 4 Then
If Me.THU.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 1
End If
If Me.FRI.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 2
End If
If Me.SAT.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 3
End If
If Me.SUN.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 4
End If
If Me.MON.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 5
End If
If Me.TUE.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 6
End If
If Me.WED.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 7
End If
If Me.PRINTFLAG.Value = False Then
Me.PROCDATE.Value = ""
End If
End If
'THURSDAY
If Weekday(Date) = 5 Then
If Me.THU.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 7
End If
If Me.FRI.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 1
End If
If Me.SAT.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 2
End If
If Me.SUN.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 3
End If
If Me.MON.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 4
End If
If Me.TUE.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 5
End If
If Me.WED.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 6
End If
If Me.PRINTFLAG.Value = False Then
Me.PROCDATE.Value = ""
End If
End If
'FRIDAY
If Weekday(Date) = 6 Then
If Me.THU.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 6
End If
If Me.FRI.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 7
End If
If Me.SAT.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 1
End If
If Me.SUN.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 2
End If
If Me.MON.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 3
End If
If Me.TUE.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 4
End If
If Me.WED.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 5
End If
If Me.PRINTFLAG.Value = False Then
Me.PROCDATE.Value = ""
End If
End If
End If
Exit_PRINTFLAG_Click:
Exit Sub
err_PRINTFLAG_Click:
MsgBox "YOU HAVE NOT DEFINED THE PROCESSING DATE. PLEASE DO SO ON THE
NEXT SCREEN THAT APPEARS, THEN CONTINUE PROCESSING LABELS. YOU WILL NEED TO
RE-MARK THIS LABEL FOR PRINTING"
Me.PRINTFLAG.Value = False
DoCmd.OpenForm "DATEPREP"
Resume Exit_PRINTFLAG_CLICK
Exit Sub
End Sub
========================
I am trying to dynamically calculate dates, to populate a field called
[DOSEDATE]
The calculations work like this.
Patients take away doses of medicine, on particular days of the [Monday to
Friday] week. The medicine doses are prepared on any day between Monday
and Friday.
1st scenario:
Clinician signs into database on Monday 12th July, and declares Wednesday
14th July as [PROCDATE]
***This is done on a form [DATEPREP] with [Text0] set to date/time, and
Text0's After Update event hides the [DATEPREP] form and opens up Patient
Records form [DUBBOLIST]***
Patient 'A' has one record, which indicates a dose of medicine is required
as a takeaway each Saturday.
Clinician opens first patient record, and sees that checkbox [SAT] is
selected. Clinician marks record for printing (checkbox) and prints 1
label on Monday 12th July. The label contains the date that the dose is
intended for, in this scenario Saturday 17 July.
Pharmacist prepares dose on Wednesday 14th July, in accordance with label
Patient 'A' attends clinic on Thursday and takes home a dose of medicine for
Saturday 17 July
2nd scenario
Clinician signs into database on Tuesday 13th July, and declares Wednesday
14th July as [PROCDATE]
Pataient 'B' has three records, one for each day that a dose of medicine is
required
Clinician opens first patient record, and sees that checkbox [SAT] is
selected. Clinician marks record for printing (checkbox)
Clinician opens second patient record, and sees that checkbox [MON] is
selected. Clinician marks record for printing (checkbox)
Clinician opens third patient record, and sees that checkbox [WED] is
selected. Clinician marks record for printing (checkbox)
Clinician then prints 3 labels on Tuesday 13th July. Each label contains
the date that the dose is intended for, 17th, 19th and 21st of July
respectively.
Pharmacist prepares doses on Friday 16th July, in accordance with labels
Patient 'B' attends clinic on Friday 16th and takes home three doses of
medicine, one for Saturday 17 July, one for Monday 19th July and one for
Wednesday 21st July.
What I need help with is code to capture the weekday part of the [PROCDATE]
and calculate the [DOSEDATE].
Only one record is allowed for any one dose. Only one dosing date checkbox
is allowed to be clicked at any one time, so there is no doubling up of
dosing dates for one record. This is because the medicine might be
different on any subsequent dose, in either type or quantity, and the
clinician and pharmacist cannot be allowed to double-dose for any one day.
So if the [PROCDATE] is Weekday=4 (Wednesday, 14 July), and the [DOSEDATE]
is Weekday=7 (Saturday 18 July), I need for the [DOSEDATE] field to be
updated dynamically. This should be done when the record is 'MARKED FOR
PRINTING' ([PRINTFLAG] checkbox value = true)
I thought this might work, but the [DOSEDATE] is not getting updated... If
someone could check the code and steer me in the right direction I'd
appreciate it... here's the code for the [PRINTFLAG] checkbox
thanks in anticipation
and for those that don't read beyond this point, thanks for your patience!!
DubboPete
=================================
Private Sub PRINTFLAG_Click()
On Error GoTo err_PRINTFLAG_Click
'MARKED FOR PRINTING
If Me.PRINTFLAG.Value = True Then
Me.PROCDATE.Value = Forms!DATEPREP![Text0]
End If
'UNMARKING PRINT FLAG
If Me.PRINTFLAG.Value = False Then
Me.PROCDATE.Value = ""
Me.[DOSE DATE].Value = ""
End If
If Me.PRINTFLAG.Value = True Then
'MONDAY
If Forms![DATEPREP]!Text0 = Weekday(Date + 1) Then
If Me.THU.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 3
End If
If Me.FRI.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 4
End If
If Me.SAT.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 5
End If
If Me.SUN.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 6
End If
If Me.MON.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 7
End If
If Me.TUE.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 8
End If
If Me.WED.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 9
End If
If Me.PRINTFLAG.Value = False Then
Me.PROCDATE.Value = ""
End If
End If
'TUESDAY
If Weekday(Date) = 3 Then
If Me.THU.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 2
End If
If Me.FRI.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 3
End If
If Me.SAT.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 4
End If
If Me.SUN.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 5
End If
If Me.MON.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 6
End If
If Me.TUE.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 7
End If
If Me.WED.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 8
End If
If Me.PRINTFLAG.Value = False Then
Me.PROCDATE.Value = ""
End If
End If
'WEDNESDAY
If Weekday(Date) = 4 Then
If Me.THU.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 1
End If
If Me.FRI.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 2
End If
If Me.SAT.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 3
End If
If Me.SUN.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 4
End If
If Me.MON.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 5
End If
If Me.TUE.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 6
End If
If Me.WED.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 7
End If
If Me.PRINTFLAG.Value = False Then
Me.PROCDATE.Value = ""
End If
End If
'THURSDAY
If Weekday(Date) = 5 Then
If Me.THU.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 7
End If
If Me.FRI.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 1
End If
If Me.SAT.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 2
End If
If Me.SUN.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 3
End If
If Me.MON.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 4
End If
If Me.TUE.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 5
End If
If Me.WED.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 6
End If
If Me.PRINTFLAG.Value = False Then
Me.PROCDATE.Value = ""
End If
End If
'FRIDAY
If Weekday(Date) = 6 Then
If Me.THU.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 6
End If
If Me.FRI.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 7
End If
If Me.SAT.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 1
End If
If Me.SUN.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 2
End If
If Me.MON.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 3
End If
If Me.TUE.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 4
End If
If Me.WED.Value = True Then
Me.[DOSE DATE].Value = PROCDATE + 5
End If
If Me.PRINTFLAG.Value = False Then
Me.PROCDATE.Value = ""
End If
End If
End If
Exit_PRINTFLAG_Click:
Exit Sub
err_PRINTFLAG_Click:
MsgBox "YOU HAVE NOT DEFINED THE PROCESSING DATE. PLEASE DO SO ON THE
NEXT SCREEN THAT APPEARS, THEN CONTINUE PROCESSING LABELS. YOU WILL NEED TO
RE-MARK THIS LABEL FOR PRINTING"
Me.PRINTFLAG.Value = False
DoCmd.OpenForm "DATEPREP"
Resume Exit_PRINTFLAG_CLICK
Exit Sub
End Sub
========================