PC Review


Reply
Thread Tools Rate Thread

Control menu through function?

 
 
Henrootje
Guest
Posts: n/a
 
      13th Oct 2006
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

 
Reply With Quote
 
 
 
 
Alessandro Baraldi
Guest
Posts: n/a
 
      13th Oct 2006

Henrootje ha scritto:

> 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


As you Write the OnAction property can contain a function to Call....!
Why you use EVAL....?
On modify the property the commandbar(Control) will generate the
call...!

To call it you need a Function...!

Es:
CommandBars('OK Revisie').Controls(" & vLaag1
&").OnAction="=ExecFunc()"

Now you Need ExecFunc() so....

Public Function ExecFunc()
msgbox "I'm still Executing the menù"
End Function

@Alex

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Menu Control and Sitemap, eliminate the home column on the menu display empire5 Microsoft VB .NET 1 11th Jan 2007 03:30 AM
Menu Control and Sitemap, eliminate the home column on the menu display empire5 Microsoft ASP .NET 1 11th Jan 2007 03:30 AM
Menu Control and Sitemap, eliminate the home column on the menu display empire5 Microsoft C# .NET 1 11th Jan 2007 03:30 AM
Not able to call a function from custom menu item that is added in word menu(File) jayrm100@yahoo.com Microsoft Word Document Management 0 9th Nov 2005 05:36 AM
control a sub/function via a dropdown menu daMike Microsoft Excel Charting 1 23rd Oct 2003 05:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:22 PM.