Default view in Forms (1 Viewer)

AnilBagga

Member
Local time
Tomorrow, 03:13
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
 

CJ_London

Super Moderator
Staff member
Local time
Today, 21:43
Joined
Feb 19, 2013
Messages
16,553
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
Tomorrow, 03:13
Joined
Apr 9, 2020
Messages
223
Manually from navigation window
 

CJ_London

Super Moderator
Staff member
Local time
Today, 21:43
Joined
Feb 19, 2013
Messages
16,553
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, 17:43
Joined
Oct 20, 2018
Messages
3,476
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

Active member
Local time
Today, 14:43
Joined
Oct 4, 2015
Messages
180
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
Tomorrow, 03:13
Joined
Apr 9, 2020
Messages
223
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
Tomorrow, 03:13
Joined
Apr 9, 2020
Messages
223
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, 17:43
Joined
Oct 20, 2018
Messages
3,476
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
Tomorrow, 03:13
Joined
Apr 9, 2020
Messages
223
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

  • MIS_fe.zip
    297.9 KB · Views: 113

CJ_London

Super Moderator
Staff member
Local time
Today, 21:43
Joined
Feb 19, 2013
Messages
16,553
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
Tomorrow, 03:13
Joined
Apr 9, 2020
Messages
223
Sorry. I used the wrong word

It is split database and not split form
 

onur_can

Active member
Local time
Today, 14:43
Joined
Oct 4, 2015
Messages
180
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

  • Database1.accdb
    1.6 MB · Views: 105

CJ_London

Super Moderator
Staff member
Local time
Today, 21:43
Joined
Feb 19, 2013
Messages
16,553
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

Top Bottom