![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a form, EmpForm with a subform, Activity. There are two controls on the mainform. First control entitled HoursWorked calculates data from two fields on the mainform,=DateDiff("s", [StartTime],[EndTime])/3600. The second control, ActivityHours calcualates data from the subform, =frmActivity.Form!TotalHrs. I need the code to put behind the Close button on the Mainform which will prevent the mainform and subform form closing unless the HoursWorked and ActivityHours are equal. Thank you for your help Ron |
#3
| |||
| |||
|
|
A_Classic_Man wrote: I have a form, EmpForm with a subform, Activity. There are two controls on the mainform. First control entitled HoursWorked calculates data from two fields on the mainform,=DateDiff("s", [StartTime],[EndTime])/3600. The second control, ActivityHours calcualates data from the subform, =frmActivity.Form!TotalHrs. I need the code to put behind the Close button on the Mainform which will prevent the mainform and subform form closing unless the HoursWorked and ActivityHours are equal. Thank you for your help Ron Perhaps something similar to the following might work. If Me.YourMainFormControlName <>_ * * * * Me.YourSubformName!YourSubformsControlName then * *Msgbox "Values don't match!" else * *Docmd.Close acForm, Me.name Endif |
#4
| |||
| |||
|
|
On Feb 14, 11:11 am, Salad <sa... (AT) oilandvinegar (DOT) com> wrote: A_Classic_Man wrote: I have a form, EmpForm with a subform, Activity. There are two controls on the mainform. First control entitled HoursWorked calculates data from two fields on the mainform,=DateDiff("s", [StartTime],[EndTime])/3600. The second control, ActivityHours calcualates data from the subform, =frmActivity.Form!TotalHrs. I need the code to put behind the Close button on the Mainform which will prevent the mainform and subform form closing unless the HoursWorked and ActivityHours are equal. Thank you for your help Ron Perhaps something similar to the following might work. If Me.YourMainFormControlName <>_ Me.YourSubformName!YourSubformsControlName then Msgbox "Values don't match!" else Docmd.Close acForm, Me.name Endif Thank you, your help is appreciated. |
#5
| |||
| |||
|
|
A_Classic_Man wrote: On Feb 14, 11:11 am, Salad <sa... (AT) oilandvinegar (DOT) com> wrote: A_Classic_Man wrote: I have a form, EmpForm with a subform, Activity. There are two controls on the mainform. First control entitled HoursWorked calculates data from two fields on the mainform,=DateDiff("s", [StartTime],[EndTime])/3600. The second control, ActivityHours calcualates data from the subform, =frmActivity.Form!TotalHrs. I need the code to put behind the Close button on the Mainform which will prevent the mainform and subform form closing unless the HoursWorked and ActivityHours are equal. Thank you for your help Ron Perhaps something similar to the following might work. If Me.YourMainFormControlName <>_ Me.YourSubformName!YourSubformsControlName then Msgbox "Values don't match!" else Docmd.Close acForm, Me.name Endif Thank you, your help is appreciated. Do realize that if there are no records in you subform it will probably error. If Me.YourSubformName.Form.Recordcount > 0 then... 'do your check endif Also, if you have an X button, it will run your code and close as well. If a record exists, you can cancel the Unload. If it's a new record I don't think there's a built in way to determine the X was trapped, so you'd get the error message and then it would close. |
![]() |
| Thread Tools | |
| Display Modes | |
| |