Define Keyword as Variable

U

Ulrich1947

Hi all,

I do want to define Keywords as a variable, if possible. For instance, I
want to have control visible or not depending on an entry in a table of
parameters referring to the user. The command i would use should state

MyControl.Visible = DLookUp("User0";"tabParameter";"UserName = XYZ")

whereby the field User0 contains either the string False or True.
The way stated above is not working, as Access does not interprete a simple
string as a Keyword.

I know, I can do this by using

IIf(DLookUp("User0";"tabParameter";"UserName = XYZ") = "False" Then
MyControl.Visible = False
Else
MyControl.Visible = True
End If

but isn't there another way to define the string that way, that Access
accepts it as a Keyword ? Much obliged for any help. Thanks.

Ulrich 1947
 
A

Allen Browne

Eval() should be able to evalutate the string "True" or "False" for you.

Use Nz() in case the record is not found.

MyControl.Visible = Eval(Nz(DLookUp("User0", "tabParameter", "UserName =
'XYZ'"), "False"))
 
Top