Detect form view change to datasheet (1 Viewer)

coypu

Registered User.
Local time
Today, 00:36
Joined
Mar 12, 2019
Messages
26
Hi, how does one detect immediately a form is changed from normal to datasheet view?
 

isladogs

MVP / VIP
Local time
Today, 00:36
Joined
Jan 14, 2017
Messages
18,216
You could add code like this:

Code:
Private Sub Form_Current()
    If Me.CurrentView = 2 Then MsgBox "Datasheet view"
End Sub

The full list of values are

Code:
Setting	Form displayed in:
0	Design view
1	Form view
2	Datasheet view
7	Layout view

Or you can prevent datasheet view completely in the form property sheet
 

coypu

Registered User.
Local time
Today, 00:36
Joined
Mar 12, 2019
Messages
26
Excellent, thanks Colin
I forgot about testing during the form's On Current event.
 

Users who are viewing this thread

Top Bottom