Using Shift And Cancel

jaydwest

JayW
Local time
Today, 03:46
Joined
Apr 22, 2003
Messages
340
I like to hang functions on form and control events on the property Dialog. They work great except for one limitation. I would like to hang a function on the Before_Update Event, for example = TestDate(), and be able to set the Cancel Parameter in the function and have the Cancel executed.

I also use the Mouse_Down event of a button to print a report. If the user holds the shift key down I print the report, if not I preview it. I have a Function that prints reports but I have to insert it in the Mouse_Down event instead of just setting the Event Property to =PrintMyReport(....). I would be great to be able to get the Shift parameter in the function.

Does anyone know any way to accomplish this. If you do it will be Christmas in February! :D

Thanks for your help!
 
The second question:
Code:
Private Sub btReport_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (Button = acLeftButton) And (Shift = 1) Then
        DoCmd.OpenReport "Wine samples", acViewPreview
    ElseIf Button = acLeftButton Then
        DoCmd.OpenReport "Wine samples"
    Else
        'do nothing
    End If
End Sub
 
jaydwest said:
I like to hang functions on form and control events on the property Dialog. They work great except for one limitation. I would like to hang a function on the Before_Update Event, for example = TestDate(), and be able to set the Cancel Parameter in the function and have the Cancel executed.
Before_Update is too late to validate information, use it merely for cosmetic things. Use the validation rule poperty of the field in the table.
 
Why do you think the BeforeUpdate event is too late to validate data. I have been doing it since Access 2.0. It works great. I prefer to validate data on the form because I have much more control to test against other fields and virtually whatever I want.

:D
 

Users who are viewing this thread

Back
Top Bottom