Changing Form's View in VBA

R

RLN

I have a form that does not display correctly.
frm1 opens frm2 via a command button.

My three problems with frm2:
1. Displays in form view when called from the button.
(should be datasheet view)
2. "Shortcut Menu" is set to "Yes", however I cannot right click in the form
to go to design view.

These properties are already set on frm2:
"Shortcut Menu is set to "Yes"
View is set to "Datasheet view" by default.
"Allow pivot view", and "allow form view" are both set to "no.

Here is my code that launches frm2:

strSQL1 = "Select Field1, Field2 FROM tblX"

'open the form
DoCmd.OpenForm "frm2"

Forms!frmCurrentBatches.RecordSource = strSQL1

Forms!frmCurrentBatches.Refresh
Forms!frmCurrentBatches.Visible = True

- - - - - - -
'When trying to set the view to datasheet,the following two lines did not
work:
'Forms!frmCurrentBatches.DefaultView = 2 'set to datasheet view
' DoCmd.OpenForm FormName:=frm2, View:=acFormDS 'set to datasheet view

Finally, I need to disallow the user the opportunity to right click on any
form they have loaded. I don't want them to have the opportunity to get to
design mode.
Is there a simple way to set the 'allow shortcut menu' property to "no" on
all of the forms when the app loads, then set that property on all forms back
to "yes" when the app closes?

Any suggestions would be helpful.

Thnx.....
 
F

fredg

I have a form that does not display correctly.
frm1 opens frm2 via a command button.

My three problems with frm2:
1. Displays in form view when called from the button.
(should be datasheet view)
2. "Shortcut Menu" is set to "Yes", however I cannot right click in the form
to go to design view.

These properties are already set on frm2:
"Shortcut Menu is set to "Yes"
View is set to "Datasheet view" by default.
"Allow pivot view", and "allow form view" are both set to "no.

Here is my code that launches frm2:

strSQL1 = "Select Field1, Field2 FROM tblX"

'open the form
DoCmd.OpenForm "frm2"

Forms!frmCurrentBatches.RecordSource = strSQL1

Forms!frmCurrentBatches.Refresh
Forms!frmCurrentBatches.Visible = True

- - - - - - -
'When trying to set the view to datasheet,the following two lines did not
work:
'Forms!frmCurrentBatches.DefaultView = 2 'set to datasheet view
' DoCmd.OpenForm FormName:=frm2, View:=acFormDS 'set to datasheet view

Finally, I need to disallow the user the opportunity to right click on any
form they have loaded. I don't want them to have the opportunity to get to
design mode.
Is there a simple way to set the 'allow shortcut menu' property to "no" on
all of the forms when the app loads, then set that property on all forms back
to "yes" when the app closes?

Any suggestions would be helpful.

Thnx.....

Regardless of the default View setting of the form, if you wish to
open it using code you MUST explicitly open it in Datasheet view.

DoCmd.OpenForm "frm2", acFormDS

will open the form, using code, in datasheet view.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top