Shortcut Menus

S

Steve

Hi,

I have a shortcut menu for use on a list box.

Some of the items in the list box can be exported, others
cant.

How can I enable/Disable the Export function on the menu,
dependent on the selected item?

Any help is much appreciated.

Cheers,
Steve
 
S

Sandra Daigle

Hi Steve,

The CommandbarControl object has an enabled property which you can toggle.
Of course you first need to get a reference to CommandBarControl object
which is the "Export" menu item on your shortcut menu. The easiest way to do
this is to assign a value to the tag property of the menu item and then use
that value with the FindControl method of the Commandbar.

How do you determine whether an item can be exported? For simplicity's sake,
let's say there is a field that you can include in the RowSource of the
listbox which gives you this information. Make sure that you've modified the
ColumnCount of the listbox so that the values will be available to you using
VBA.

The following will work assuming that the Listbox is a simple listbox (else
AfterUpdate won't work). For this example the Shortcut menu is named
'Custom1' and the tag of the menuitem I am enabling/disabling is
'CustomButton1'. The boolean value which tells me whether to enable or
disable the item is in the 3rd column of the listbox rowsource.

Private Sub List16_AfterUpdate()
Dim cbc As CommandBarControl
Set cbc = CommandBars("Custom1").FindControl(, , "Custombutton1")
cbc.Enabled = Me.List16.Column(2)
End Sub
 
S

Steve

Thanks for the reply Sandra.

When trying this I get a compile error on the Dim line,
saying; User-defined type not defined!

I am using Access97, if this is the problem.....

Any ideas?

Cheers,
Steve.
-----Original Message-----
Hi Steve,

The CommandbarControl object has an enabled property which you can toggle.
Of course you first need to get a reference to CommandBarControl object
which is the "Export" menu item on your shortcut menu. The easiest way to do
this is to assign a value to the tag property of the menu item and then use
that value with the FindControl method of the Commandbar.

How do you determine whether an item can be exported? For simplicity's sake,
let's say there is a field that you can include in the RowSource of the
listbox which gives you this information. Make sure that you've modified the
ColumnCount of the listbox so that the values will be available to you using
VBA.

The following will work assuming that the Listbox is a simple listbox (else
AfterUpdate won't work). For this example the Shortcut menu is named
'Custom1' and the tag of the menuitem I am enabling/disabling is
'CustomButton1'. The boolean value which tells me whether to enable or
disable the item is in the 3rd column of the listbox rowsource.

Private Sub List16_AfterUpdate()
Dim cbc As CommandBarControl
Set cbc = CommandBars("Custom1").FindControl (, , "Custombutton1")
cbc.Enabled = Me.List16.Column(2)
End Sub

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Hi,

I have a shortcut menu for use on a list box.

Some of the items in the list box can be exported, others
cant.

How can I enable/Disable the Export function on the menu,
dependent on the selected item?

Any help is much appreciated.

Cheers,
Steve

.
 
S

Sandra Daigle

Check your references, you need a reference to the Microsoft Office XX
Object Library (8.0 for Office97). To add this reference open a module then
click Tools->References. Make sure you are *not* in debug mode when you
attempt to modify the references.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Thanks for the reply Sandra.

When trying this I get a compile error on the Dim line,
saying; User-defined type not defined!

I am using Access97, if this is the problem.....

Any ideas?

Cheers,
Steve.
-----Original Message-----
Hi Steve,

The CommandbarControl object has an enabled property which you can
toggle. Of course you first need to get a reference to
CommandBarControl object which is the "Export" menu item on your
shortcut menu. The easiest way to do this is to assign a value to
the tag property of the menu item and then use that value with the
FindControl method of the Commandbar.

How do you determine whether an item can be exported? For
simplicity's sake, let's say there is a field that you can include
in the RowSource of the listbox which gives you this information.
Make sure that you've modified the ColumnCount of the listbox so
that the values will be available to you using VBA.

The following will work assuming that the Listbox is a simple
listbox (else AfterUpdate won't work). For this example the Shortcut
menu is named 'Custom1' and the tag of the menuitem I am
enabling/disabling is 'CustomButton1'. The boolean value which tells
me whether to enable or disable the item is in the 3rd column of the
listbox rowsource.

Private Sub List16_AfterUpdate()
Dim cbc As CommandBarControl
Set cbc = CommandBars("Custom1").FindControl (, , "Custombutton1")
cbc.Enabled = Me.List16.Column(2)
End Sub

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Hi,

I have a shortcut menu for use on a list box.

Some of the items in the list box can be exported, others
cant.

How can I enable/Disable the Export function on the menu,
dependent on the selected item?

Any help is much appreciated.

Cheers,
Steve

.
 
S

Steve

Ok, Thanks Sandra.

Will I need to do this on other users PC's? Or does the
reference stay with the Database?

Thanx for your help,
Steve.
-----Original Message-----
Check your references, you need a reference to the Microsoft Office XX
Object Library (8.0 for Office97). To add this reference open a module then
click Tools->References. Make sure you are *not* in debug mode when you
attempt to modify the references.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Thanks for the reply Sandra.

When trying this I get a compile error on the Dim line,
saying; User-defined type not defined!

I am using Access97, if this is the problem.....

Any ideas?

Cheers,
Steve.
-----Original Message-----
Hi Steve,

The CommandbarControl object has an enabled property which you can
toggle. Of course you first need to get a reference to
CommandBarControl object which is the "Export" menu item on your
shortcut menu. The easiest way to do this is to assign a value to
the tag property of the menu item and then use that value with the
FindControl method of the Commandbar.

How do you determine whether an item can be exported? For
simplicity's sake, let's say there is a field that you can include
in the RowSource of the listbox which gives you this information.
Make sure that you've modified the ColumnCount of the listbox so
that the values will be available to you using VBA.

The following will work assuming that the Listbox is a simple
listbox (else AfterUpdate won't work). For this example the Shortcut
menu is named 'Custom1' and the tag of the menuitem I am
enabling/disabling is 'CustomButton1'. The boolean value which tells
me whether to enable or disable the item is in the 3rd column of the
listbox rowsource.

Private Sub List16_AfterUpdate()
Dim cbc As CommandBarControl
Set cbc = CommandBars("Custom1").FindControl (, , "Custombutton1")
cbc.Enabled = Me.List16.Column(2)
End Sub

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.


Steve wrote:
Hi,

I have a shortcut menu for use on a list box.

Some of the items in the list box can be exported, others
cant.

How can I enable/Disable the Export function on the menu,
dependent on the selected item?

Any help is much appreciated.

Cheers,
Steve

.

.
 
S

Sandra Daigle

Hi Steve,

The reference will stay with the database and in most cases you won't have
any problems. However, there is always the possiblity that the file being
referenced is moved or there is some other issue which causes the reference
to be be broken. You might want to read Douglas Steeles article on
references
(http://members.rogers.com/douglas.j.steele/AccessReferenceErrors.html) for
more on this and how to proactively avoid problems (be sure to also read the
linked article to Michka's article on references
http://www.trigeminal.com/usenet/usenet026.asp).

The vast majority of my work is in one location and I am 99% in control of
what happens to all the PCs with my applications. It's a dream world as far
as this type of issue is concerned. :)

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Ok, Thanks Sandra.

Will I need to do this on other users PC's? Or does the
reference stay with the Database?

Thanx for your help,
Steve.
-----Original Message-----
Check your references, you need a reference to the Microsoft Office
XX Object Library (8.0 for Office97). To add this reference open a
module then click Tools->References. Make sure you are *not* in
debug mode when you attempt to modify the references.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Thanks for the reply Sandra.

When trying this I get a compile error on the Dim line,
saying; User-defined type not defined!

I am using Access97, if this is the problem.....

Any ideas?

Cheers,
Steve.

-----Original Message-----
Hi Steve,

The CommandbarControl object has an enabled property which you can
toggle. Of course you first need to get a reference to
CommandBarControl object which is the "Export" menu item on your
shortcut menu. The easiest way to do this is to assign a value to
the tag property of the menu item and then use that value with the
FindControl method of the Commandbar.

How do you determine whether an item can be exported? For
simplicity's sake, let's say there is a field that you can include
in the RowSource of the listbox which gives you this information.
Make sure that you've modified the ColumnCount of the listbox so
that the values will be available to you using VBA.

The following will work assuming that the Listbox is a simple
listbox (else AfterUpdate won't work). For this example the
Shortcut menu is named 'Custom1' and the tag of the menuitem I am
enabling/disabling is 'CustomButton1'. The boolean value which
tells me whether to enable or disable the item is in the 3rd
column of the listbox rowsource.

Private Sub List16_AfterUpdate()
Dim cbc As CommandBarControl
Set cbc = CommandBars("Custom1").FindControl
(, , "Custombutton1")
cbc.Enabled = Me.List16.Column(2)
End Sub

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this
newsgroup.


Steve wrote:
Hi,

I have a shortcut menu for use on a list box.

Some of the items in the list box can be exported, others
cant.

How can I enable/Disable the Export function on the menu,
dependent on the selected item?

Any help is much appreciated.

Cheers,
Steve

.

.
 
S

Steve

OK.

Cheers for the help Sandra, Ive got it working a treat
now :))

Happy New Year!

Steve.
-----Original Message-----
Hi Steve,

The reference will stay with the database and in most cases you won't have
any problems. However, there is always the possiblity that the file being
referenced is moved or there is some other issue which causes the reference
to be be broken. You might want to read Douglas Steeles article on
references
(http://members.rogers.com/douglas.j.steele/AccessReference
Errors.html) for
more on this and how to proactively avoid problems (be sure to also read the
linked article to Michka's article on references
http://www.trigeminal.com/usenet/usenet026.asp).

The vast majority of my work is in one location and I am 99% in control of
what happens to all the PCs with my applications. It's a dream world as far
as this type of issue is concerned. :)

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Ok, Thanks Sandra.

Will I need to do this on other users PC's? Or does the
reference stay with the Database?

Thanx for your help,
Steve.
-----Original Message-----
Check your references, you need a reference to the Microsoft Office
XX Object Library (8.0 for Office97). To add this reference open a
module then click Tools->References. Make sure you are *not* in
debug mode when you attempt to modify the references.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.


Steve wrote:
Thanks for the reply Sandra.

When trying this I get a compile error on the Dim line,
saying; User-defined type not defined!

I am using Access97, if this is the problem.....

Any ideas?

Cheers,
Steve.

-----Original Message-----
Hi Steve,

The CommandbarControl object has an enabled property which you can
toggle. Of course you first need to get a reference to
CommandBarControl object which is the "Export" menu item on your
shortcut menu. The easiest way to do this is to assign a value to
the tag property of the menu item and then use that value with the
FindControl method of the Commandbar.

How do you determine whether an item can be exported? For
simplicity's sake, let's say there is a field that you can include
in the RowSource of the listbox which gives you this information.
Make sure that you've modified the ColumnCount of the listbox so
that the values will be available to you using VBA.

The following will work assuming that the Listbox is a simple
listbox (else AfterUpdate won't work). For this example the
Shortcut menu is named 'Custom1' and the tag of the menuitem I am
enabling/disabling is 'CustomButton1'. The boolean value which
tells me whether to enable or disable the item is in the 3rd
column of the listbox rowsource.

Private Sub List16_AfterUpdate()
Dim cbc As CommandBarControl
Set cbc = CommandBars("Custom1").FindControl
(, , "Custombutton1")
cbc.Enabled = Me.List16.Column(2)
End Sub

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this
newsgroup.


Steve wrote:
Hi,

I have a shortcut menu for use on a list box.

Some of the items in the list box can be exported, others
cant.

How can I enable/Disable the Export function on the menu,
dependent on the selected item?

Any help is much appreciated.

Cheers,
Steve

.

.

.
 
S

Sandra Daigle

You're most welcome - Happy New Year to you too!
--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

OK.

Cheers for the help Sandra, Ive got it working a treat
now :))

Happy New Year!

Steve.
-----Original Message-----
Hi Steve,

The reference will stay with the database and in most cases you
won't have any problems. However, there is always the possiblity
that the file being referenced is moved or there is some other issue
which causes the reference to be be broken. You might want to read
Douglas Steeles article on references
(http://members.rogers.com/douglas.j.steele/AccessReference
Errors.html) for
more on this and how to proactively avoid problems (be sure to also
read the linked article to Michka's article on references
http://www.trigeminal.com/usenet/usenet026.asp).

The vast majority of my work is in one location and I am 99% in
control of what happens to all the PCs with my applications. It's a
dream world as far as this type of issue is concerned. :)

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Ok, Thanks Sandra.

Will I need to do this on other users PC's? Or does the
reference stay with the Database?

Thanx for your help,
Steve.

-----Original Message-----
Check your references, you need a reference to the Microsoft Office
XX Object Library (8.0 for Office97). To add this reference open a
module then click Tools->References. Make sure you are *not* in
debug mode when you attempt to modify the references.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this
newsgroup.


Steve wrote:
Thanks for the reply Sandra.

When trying this I get a compile error on the Dim line,
saying; User-defined type not defined!

I am using Access97, if this is the problem.....

Any ideas?

Cheers,
Steve.

-----Original Message-----
Hi Steve,

The CommandbarControl object has an enabled property which you
can toggle. Of course you first need to get a reference to
CommandBarControl object which is the "Export" menu item on your
shortcut menu. The easiest way to do this is to assign a value to
the tag property of the menu item and then use that value with
the FindControl method of the Commandbar.

How do you determine whether an item can be exported? For
simplicity's sake, let's say there is a field that you can
include in the RowSource of the listbox which gives you this
information. Make sure that you've modified the ColumnCount of
the listbox so that the values will be available to you using
VBA.

The following will work assuming that the Listbox is a simple
listbox (else AfterUpdate won't work). For this example the
Shortcut menu is named 'Custom1' and the tag of the menuitem I am
enabling/disabling is 'CustomButton1'. The boolean value which
tells me whether to enable or disable the item is in the 3rd
column of the listbox rowsource.

Private Sub List16_AfterUpdate()
Dim cbc As CommandBarControl
Set cbc = CommandBars("Custom1").FindControl
(, , "Custombutton1")
cbc.Enabled = Me.List16.Column(2)
End Sub

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this
newsgroup.


Steve wrote:
Hi,

I have a shortcut menu for use on a list box.

Some of the items in the list box can be exported, others
cant.

How can I enable/Disable the Export function on the menu,
dependent on the selected item?

Any help is much appreciated.

Cheers,
Steve

.

.

.
 

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