Setting form view

G

Guest

I have created a generic form opening module.

Sub OpenFormSecure(strFormName As String, Optional strOpenView As String)

The module is passed the form name and the view (Normal, Datasheet). for
example, I might call the module with the code

OpenFormSecure ("frmMenu", "acNormal")

After some checking of the security for the person requesting the form the
following line is used

DoCmd.OpenForm strFormName, strOpenView

Problem is that it doesnt like acNormal or acFormDS as a string value. Any
suggestions as to how I can pass the view value?
 
J

John W. Vinson

DoCmd.OpenForm strFormName, strOpenView

Problem is that it doesnt like acNormal or acFormDS as a string value. Any
suggestions as to how I can pass the view value?

OpenForm expects a number value - not a text string. acNormal and
acFormDS are VBA constants for integer number values (I don't happen
to have them memorized though). Let's see:

?acnormal
0
?acFormDS
3

But unfortunately my idea of using

Eval(strOpenView)

fails...! You'll probably need to pass a number, or use a Switch()
function call or a DLookUp in a table (which you'll need to create) to
translate the string to a number.

John W. Vinson [MVP]
 
G

Guest

Hi John

Thanks. That worked. Datasheet is 3 and Normal is 0. Changed the
parameter to a number and passed the number.
 

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