Default view in Forms (1 Viewer)

AnilBagga

Member
Local time
Today, 14:15
Joined
Apr 9, 2020
Messages
92
Some forms do not open in the specified Default view like the one below. It always opens in the single form view. What could be the reason?

1596880771967.png
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:45
Joined
Feb 19, 2013
Messages
12,444
how are you opening the form? using docmd.openform? as a subform to a main form? manually from the navigation window?
 

AnilBagga

Member
Local time
Today, 14:15
Joined
Apr 9, 2020
Messages
92
Manually from navigation window
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:45
Joined
Feb 19, 2013
Messages
12,444
In that case I don't have an explanation - single form is the default position when a form is created. Is the screenshot you provided for a form that is opening as single form, even tho the default is datasheet? or just an illustration of what it should be?

suggest upload a copy of your db with a form that is not opening as expected
 

Micron

AWF VIP
Local time
Today, 04:45
Joined
Oct 20, 2018
Messages
3,467
Just turn off Allow Form View? It's what I do when a form doesn't open as specified by the default property setting. I've always just assumed it had something to do with having saved a form while it was in some other view, thus 'remembering' that view from then on. Oddly enough, I didn't try saving it in the desired view, I just set the one I didn't want to No.
 

onur_can

Member
Local time
Today, 01:45
Joined
Oct 4, 2015
Messages
103
you must open it from another form in design mode.
such code may have been written.
Code:
Private Sub Form_Open(Cancel As Integer)
Me.Form.DefaultView = 2
End Sub
 
Last edited:

AnilBagga

Member
Local time
Today, 14:15
Joined
Apr 9, 2020
Messages
92
Just turn off Allow Form View? It's what I do when a form doesn't open as specified by the default property setting. I've always just assumed it had something to do with having saved a form while it was in some other view, thus 'remembering' that view from then on. Oddly enough, I didn't try saving it in the desired view, I just set the one I didn't want to No.
did not work ! I turned both form and layout view to No and datasheet to yes. Still does not work
 

AnilBagga

Member
Local time
Today, 14:15
Joined
Apr 9, 2020
Messages
92
you must open it from another form in design mode.
such code may have been written.
Code:
Private Sub Form_Open(Cancel As Integer)
Me.Form.DefaultView = 2
End Sub
When you say in another form in Design mode, what do you mean?
Right now views are as under

1596948968241.png


In the same form I added this code and got an error and on debugging get the error as below


1596949047575.png

1596949107417.png
 
Last edited:

Micron

AWF VIP
Local time
Today, 04:45
Joined
Oct 20, 2018
Messages
3,467
did not work ! I turned both form and layout view to No and datasheet to yes. Still does not work
Then I suspect you have Load or Open event code on that form, or code that opens the form which overrides the property settings. Perhaps you should post those events or a zipped copy of the database.
 

AnilBagga

Member
Local time
Today, 14:15
Joined
Apr 9, 2020
Messages
92
Then I suspect you have Load or Open event code on that form, or code that opens the form which overrides the property settings. Perhaps you should post those events or a zipped copy of the database.
I am using a split form and the FE file is enclosed. I am not at liberty to share the BE file. I hope this will help in analysing the problem

The form in question is "frmCustomerMaster"
 

Attachments

CJ_London

Super Moderator
Staff member
Local time
Today, 09:45
Joined
Feb 19, 2013
Messages
12,444
think split form is the reason - that shows a datasheet at the bottom and a single form at the top - so the datasheet settings will have no effect

suggest try remaking the form but as a normal form.
 
Last edited:

AnilBagga

Member
Local time
Today, 14:15
Joined
Apr 9, 2020
Messages
92
Sorry. I used the wrong word

It is split database and not split form
 

onur_can

Member
Local time
Today, 01:45
Joined
Oct 4, 2015
Messages
103
Code:
Private Sub cmdSingleForm_Click()
DoCmd.OpenForm "Form2", acDesign, , , , acHidden
Forms!Form2.DefaultView = 0
DoCmd.Close acForm, "Form2", acSaveYes
DoCmd.OpenForm "Form2"
End Sub

Private Sub cmdContinuousForm_Click()
DoCmd.OpenForm "Form2", acDesign, , , , acHidden
Forms!Form2.DefaultView = 1
DoCmd.Close acForm, "Form2", acSaveYes
DoCmd.OpenForm "Form2"
End Sub

Private Sub cmdDataSheetForm_Click()
DoCmd.OpenForm "Form2", acDesign, , , , acHidden
Forms!Form2.DefaultView = 2
DoCmd.Close acForm, "Form2", acSaveYes

'Pay Attention Here!
DoCmd.OpenForm "Form2", acFormDS
End Sub

Check out the differences between views.
 

Attachments

CJ_London

Super Moderator
Staff member
Local time
Today, 09:45
Joined
Feb 19, 2013
Messages
12,444
When I open the form, i get errors because there is no linked table. I remove the recordsource, filter and sort properties and it opened fine as as a datasheet.

So not sure why you are unable to do so
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom