hiii all dears
i have three forms , mainfrm , inside it [FONT="]OrdersSubFrm , inside it [/FONT][FONT="]OrdDetSubFrm .
i have a code to allert user if there are any changes , for any control in any form of this three forms. , after three days of the current date.
i use this codes in the Form_BeforeUpdate event :
for the main form i use :
[/FONT]
[FONT="]
in the [/FONT][FONT="]OrdersSubFrm (sub form):
[/FONT]
[FONT="]
and in the [/FONT][FONT="][FONT="]OrdDetSubFrm (sub sub form) :
note : i have a listbox in the [/FONT][/FONT][FONT="]OrdersSubFrm (sub form) , under DblClick event the same code , but runs action queries as :
Q: how to build a module [/FONT] to replace all the above codes ?
i have three forms , mainfrm , inside it [FONT="]OrdersSubFrm , inside it [/FONT][FONT="]OrdDetSubFrm .
i have a code to allert user if there are any changes , for any control in any form of this three forms. , after three days of the current date.
i use this codes in the Form_BeforeUpdate event :
for the main form i use :
[/FONT]
Code:
[LEFT][FONT="][SIZE=3]Dim MyDate
Dim LValue As Integer
Dim MnthCnt As String
MyDate = DateSerial(Year(Me!OrdersSubFrm.Form!OrderDate), Month(Me!OrdersSubFrm.Form!OrderDate), Day(Me!OrdersSubFrm.Form!OrderDate))
LValue = DateDiff("d", MyDate, Date)
If LValue < 10 Then
MnthCnt = "day"
Else
MnthCnt = "days"
End If
If LValue >= 3 Then
If MsgBox("Dear user It has been " & " ( " & LValue & " ) " & MnthCnt & vbCrLf & _
" from the date of this visit for patient:" & "" & Me.PtName & vbCrLf & _
"Do you want to change the information of this patient, to confirm the changes Choose Yes, to cancel select No. ", vbInformation + vbMsgBoxRtlReading + vbMsgBoxRight + vbYesNo, " Change Confirmation " & " " & Me.Parent!PtName) = vbYes Then
Cancel = False
Else
Cancel = True
DoCmd.RunCommand acCmdUndo
End If
End If
End If
[/SIZE][/FONT][/LEFT]
[SIZE=3] [/SIZE]
in the [/FONT][FONT="]OrdersSubFrm (sub form):
[/FONT]
Code:
Dim MyDate
Dim LValue As Integer
Dim MnthCnt As String
MyDate = DateSerial(Year(Me!OrderDate), Month(Me!OrderDate), Day(Me!OrderDate))
LValue = DateDiff("d", MyDate, Date)
If LValue < 10 Then
MnthCnt = "day"
Else
MnthCnt = "days"
End If
If LValue >= 3 Then
If MsgBox("Dear user It has been " & " ( " & LValue & " ) " & MnthCnt & vbCrLf & _
" from the date of this visit for patient:" & "" & Me.Parent.PtName & vbCrLf & _
" Do you want to change the information of this patient, to confirm the changes Choose Yes, to cancel select No. ", vbInformation + vbMsgBoxRtlReading + vbMsgBoxRight + vbYesNo, " Change Confirmation " & " " & Me.Parent!PtName) = vbYes Then Then
Cancel = False
Else
Cancel = True
DoCmd.RunCommand acCmdUndo
End If
End If
and in the [/FONT][FONT="][FONT="]OrdDetSubFrm (sub sub form) :
Code:
Dim MyDate
Dim LValue As Integer
Dim MnthCnt As String
MyDate = DateSerial(Year(Me.Parent!OrderDate), Month(Me.Parent!OrderDate), Day(Me.Parent!OrderDate))
LValue = DateDiff("d", MyDate, Date)
If LValue < 10 Then
MnthCnt = "day"
Else
MnthCnt = "days"
End If
If LValue >= 3 Then
If MsgBox("Dear user It has been " & " ( " & LValue & " ) " & MnthCnt & vbCrLf & _
" from the date of this visit for patient:" & " " & Me.Parent.Parent!PtName & vbCrLf & _
" Do you want to change the information of this patient, to confirm the changes Choose Yes, to cancel select No. ", vbInformation + vbMsgBoxRtlReading + vbMsgBoxRight + vbYesNo, " Change Confirmation " & " " & Me.Parent!PtName) = vbYes Then
Cancel = False
Else
Cancel = True
DoCmd.RunCommand acCmdUndo
End If
End If
Code:
Dim MyDate
Dim LValue As Integer
Dim MnthCnt As String
MyDate = DateSerial(Year(Me!OrderDate), Month(Me!OrderDate), Day(Me!OrderDate))
LValue = DateDiff("d", MyDate, Date)
If LValue < 10 Then
MnthCnt = "day"
Else
MnthCnt = "days"
End If
If LValue >= 3 Then
If MsgBox("Dear user It has been" & " ( " & LValue & " ) " & MnthCnt & vbCrLf & _
"from the date of this visit for this patient :" & "" & Me.Parent.PtName & vbCrLf & _
"Do you want to change the information of this patient, to confirm the changes Choose Yes, to cancel select No. ", vbInformation + vbMsgBoxRtlReading + vbMsgBoxRight + vbYesNo, " Change Confirmation " & " " & Me.Parent!PtName) = vbYes Then
Cancel = False
DoCmd.SetWarnings False
DoCmd.OpenQuery "Q4"
DoCmd.SetWarnings True
Me!OrdDetSubFrm.Form.Requery
Else
Cancel = True
End If
Else
DoCmd.SetWarnings False
DoCmd.OpenQuery "Q4"
DoCmd.SetWarnings True
Me!OrdDetSubFrm.Form.Requery
End If