Default view in Forms

AnilBagga

Member
Local time
Today, 16:55
Joined
Apr 9, 2020
Messages
223
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
 
how are you opening the form? using docmd.openform? as a subform to a main form? manually from the navigation window?
 
Manually from navigation window
 
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
 
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.
 
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:
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
 
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:
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.
 
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

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:
Sorry. I used the wrong word

It is split database and not split form
 
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

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

Back
Top Bottom