Test for Form View?

aimeepeter

Registered User.
Local time
Today, 15:45
Joined
May 12, 2008
Messages
11
Hello all,
I have some code that automatically fills in unbound fields on my form but the code produces an error (#2455) in datasheet view.

I use the IsLoaded function to test if a form is open in form or datashet view but, is there a way to test if a form is open in form view only?

This is the code to which I would like to add a test for the form being in form view before the code proceeds:

If Me.ShowCity = "New York" Then
Me.subfrmPaperwork.Form!chkNA = True
Me.subfrmPaperwork.Form!chkNA2 = True
Me.subfrmPaperwork.Form!chkEUR = False
Me.subfrmPaperwork.Form!chkEUR2 = False
ElseIf Me.ShowCity = "Milan" Or Me.ShowCity = "Paris" Then
Me.subfrmPaperwork.Form!chkNA = False
Me.subfrmPaperwork.Form!chkNA2 = False
Me.subfrmPaperwork.Form!chkEUR = True
Me.subfrmPaperwork.Form!chkEUR2 = True
End If

Cheers!
 
Assuming you're checking from within the form itself:
Private Sub Form_Load()
If Me.CurrentView = 1 Then
'Code for Single Form View
ElseIf Me.CurrentView = 2 Then
'Code for Datasheet View
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom