Setting AllowFormView at runtime

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to use the same form in two different parts of my application. I one
place I want to allow form view, in another place I want to disallow form
view.

The form is defined as allowing form view. I tried to do the following to
prevent form view in VBA.

Forms!CheckOut.AllowFormView = False

I get the message:

"Line Summary System (TEST) cann't find the form 'CheckOut' referred to in a
macro expression or Visual Basic Code.

Also, Forms("CheckOut").AllowFormView = False gives me the same error.

If I try to open the form first,

DoCmd.OpenForm "CheckOut", acFormDS, , , acFormReadOnly
Forms("CheckOut").AllowFormView = False

It opens the form OK, but on the second line I get the error message:

"To set this propery, open the form or report in Design view"


Any suggestions?

Regards,
Leif
 
Mybe there is a better way doing that, but you can try opening the form in
design view first, change the setting and then open the form

DoCmd.OpenForm "CheckOut", acDesign
Forms!CheckOut.AllowFormView = False
DoCmd.OpenForm "CheckOut", acFormDS, , , acFormReadOnly
 
Thanks for your reply.

What you suggest does work, but the form is asking to be saved when you
exit. After some experimentation I came up with the following:

DoCmd.OpenForm "CheckOut", acFormDS, , , acFormReadOnly
Forms("CheckOut").ViewsAllowed = 2 'Datasheet only
 
Back
Top