By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,830 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,830 IT Pros & Developers. It's quick & easy.

Changing Form's view in VBA

P: n/a
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,these 2 lines did not work...
'Forms!frmCurrentBatches.DefaultView = 2
' DoCmd.OpenForm FormName:=frm2, View:=acFormDS

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.....

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Here's the answer to Problem # 1

When calling one form from another form, you have to explicitly call it in
Datasheet View by using the View parameter, acFormDS. This has to be done
regardless of the default view that's set for the form.

DoCmd.OpenForm "frm2", acFormDS

Good luck in finding answers to the rest of your questions!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200806/1

Jun 27 '08 #2

P: n/a
Linq Adams gave you the answer to #1, so let's look at #2.

What version of Access is this?
If A2007, and this is a subform, get the April 11 hotfix:
http://support.microsoft.com/kb/935875

I didn't follow the last part: seems like you want to right-click on the
form, not be able to right-click on the form.

Perhaps you could create an MDE (or ACCDE) for your users. They won't be
able to switch to design view for forms, reports, or code.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"RLN" <no*******@devdex.comwrote in message
news:12**************@news.newsfeeds.com...
>
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,these 2 lines did not work...
'Forms!frmCurrentBatches.DefaultView = 2
' DoCmd.OpenForm FormName:=frm2, View:=acFormDS

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?
Jun 27 '08 #3

P: n/a
RLN


Yes, Linq's solution worked.
Looks like the MDE might be the way to go.
I have never deployed MDE's before. Are there any known 'gotchas' to
watch for when building the MDE (aside from making sufficient backups of
the .mdb)?
I can search MSDN/TEchNet for that answer, but I just wondered if there
were others not listed that you may have encountered.

Thanks,
RLN

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #4

P: n/a
MDEs are quite easy: give it a shot.
Because you retain your MDB, you are not easily snookered.

The main 'gotchas' have to do with running across different versions of
Access, or on different computers. You can only create an MDE using the
version for the file format. For example, Access 2002, 2003, and 2007 can
create an MDB in A2000 format, but only A2000 can create the MDE. The later
versions can use the A2000 MDE: they just can't create it.

A2002 and 2003 share the same file format, so you do need to watch the
versions there. If you create an MDE in this file format in A2003, you
cannnot use it in A2002. But create it in A2002, and you can use it in the
later versions.

If your MDE will be used on other computers too, be careful about the
library references. Your MDE won't work if the other computers lack the
library you used, or if they have a different version of the library.

In general, therefore, you want to keep to the minimal references: typically
VBA, Access and DAO. Access will automatically sort these out across
versions (from 2000 to 2007.)

More info on references:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"RLN" <no*******@devdex.comwrote in message
news:12**************@news.newsfeeds.com...
>
Yes, Linq's solution worked.
Looks like the MDE might be the way to go.
I have never deployed MDE's before. Are there any known 'gotchas' to
watch for when building the MDE (aside from making sufficient backups of
the .mdb)?
I can search MSDN/TEchNet for that answer, but I just wondered if there
were others not listed that you may have encountered.
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.