Re: Data Update

dr223

Registered User.
Local time
Today, 04:45
Joined
Nov 15, 2007
Messages
219
Re: Data Update

Hi

I am trying to create a pop up box which will highlight some change has been done on a record and at the same time save the date and time it took place. The code is as follows;

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Me.NewRecord Then
If MsgBox("Data will be saved, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
Cancel = True
End If
Else
If MsgBox("Data will be modified, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
Cancel = True
Else

Forms![StudentDetails1].txtlastupdated = Now() '<<< Use NOW to get the date and time

End If
End If

End Sub



This works perfectly with the date and time. Whenever a field is updated in the main form or sub-form the date and time is recorded.

However, the problem I am facing now is that when a field is changed in the main form and when the pop box comes saying;

Confirm

Data will be modified, Are you sure?
Yes No

When I select No, the following is shown

"The DoMenuItem action was Cancelled"

and changed field remains the same, instead of going back to its original form.

With subform it is an entirely different scenario it will never let you do anything else unless you accept the change, which in other occassions you won't want to.
i.e., the pop box keeps popping when you select NO until you select YES and the change is made.

Whats the problem with the syntax.


Thank you.
 
have you tried stepping through the sub in debug mode to see when this mystery call to the domenuitem is occuring?
 
Thanks I have sorted it.

I have another problem though, I am working with subform too. I want to sum feeamount. I imported a text box on the Form Footer and used the =Sum([Fee]) on the control source. However, when I go on the form view I dont see the text box nor the value.

What am doing wrong?

Thanks
 
if you are trying to show the total of the items in the subform on the FORM footer i should put the calculated textbox on the sub form footer (hide it if you wanT). Then set the record source of the textbox on the main form to the textbox calculating the value on the subform. Make sure you use the correct syntax for that ie =Forms![mainformName].Form![Controlname of the subform]![calculated textbox on subform]
 

Users who are viewing this thread

Back
Top Bottom