H
Henrootje
I tried to write a function that will allow me to control the menubar
of an access application that I am developing.
This is what I got but as you see it generates a string and I do not
know how to execute this...
Are there any suggestions as to how I could do this?
----------------------------------------------------------code-------------------------------------------------------
Function fMenu(vOnOff As Boolean, vLaag1 As Integer, Optional vLaag2 As
Integer, Optional vLaag3 As Integer)
'With this code the menuitems get enabled/visible
'fMenu(1, 2, 1)for example will enable the first command in the second
item of the topmenu
Dim vAction
Dim vState
Dim vOpdracht
If vOnOff = 1 Then 'translate 1 and 0 to true or false
vState = "True"
Else
vState = "False"
End If
If vLaag2 = 0 Then 'if it concerns second layer, anything gets
invisible instead of disabled
vAction = "Enabled"
vOpdracht = "CommandBars('OK Revisie').Controls(" & vLaag1 & ")." &
vAction & "=" & vState
GoTo Uitgang
Else
vAction = "Visible"
If vLaag3 = 0 Then
vOpdracht = "CommandBars('OK Revisie').Controls(" & vLaag1 &
").Controls(" & vLaag2 & ")." & vAction & "=" & vState
GoTo Uitgang
Else
vOpdracht = "CommandBars('OK Revisie').Controls(" & vLaag1 &
").Controls(" & vLaag2 & ").Controls(" & vLaag3 & ")." & vAction & "="
& vState
GoTo Uitgang
End If
End If
Uitgang:
Debug.Print Eval(vOpdracht)
End Function
of an access application that I am developing.
This is what I got but as you see it generates a string and I do not
know how to execute this...
Are there any suggestions as to how I could do this?
----------------------------------------------------------code-------------------------------------------------------
Function fMenu(vOnOff As Boolean, vLaag1 As Integer, Optional vLaag2 As
Integer, Optional vLaag3 As Integer)
'With this code the menuitems get enabled/visible
'fMenu(1, 2, 1)for example will enable the first command in the second
item of the topmenu
Dim vAction
Dim vState
Dim vOpdracht
If vOnOff = 1 Then 'translate 1 and 0 to true or false
vState = "True"
Else
vState = "False"
End If
If vLaag2 = 0 Then 'if it concerns second layer, anything gets
invisible instead of disabled
vAction = "Enabled"
vOpdracht = "CommandBars('OK Revisie').Controls(" & vLaag1 & ")." &
vAction & "=" & vState
GoTo Uitgang
Else
vAction = "Visible"
If vLaag3 = 0 Then
vOpdracht = "CommandBars('OK Revisie').Controls(" & vLaag1 &
").Controls(" & vLaag2 & ")." & vAction & "=" & vState
GoTo Uitgang
Else
vOpdracht = "CommandBars('OK Revisie').Controls(" & vLaag1 &
").Controls(" & vLaag2 & ").Controls(" & vLaag3 & ")." & vAction & "="
& vState
GoTo Uitgang
End If
End If
Uitgang:
Debug.Print Eval(vOpdracht)
End Function