473,438 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,438 software developers and data experts.

Toggle button on the toolbar

Hi

How can I create a toggle button on a toolbar that would enable/disable
editing on the current form?

Thanks

Regards
Nov 13 '05 #1
2 3337
Toggle the AllowEdits property in the Open event of the form.
Me.AllowEdits = Not(Me.AllowEdits)

or something along those lines.

Nov 13 '05 #2
John wrote:
How can I create a toggle button on a toolbar that would enable/disable
editing on the current form?


I'll assume you know how to create a custom menu and menu item. If not
write back and I'll write the "prequel" to the following! 8)

Write a function and save in a standard module. The function is as
written in air code following my comments below.

Make the function the on action item for the menu item, ie, for the
following, you need to enter:

=fToggleEditNamedForm(Forms!MyForm)

The Menu item can be called "Edit Form" or something and will be
ticked/depressed when in edit mode and unticked/not depressed when not
in edit mode. The "State" property use in my code below will add a tick
beside the menu item if this is a tool bar (WARNING, if you have a
picture for the item, the tick will NOT show) or depressed/not depressed
if this is a menu bar.

Alternately, instead of Forms!MyForm as an argument, you may choose to
use Screen.ActiveForm, but make certain when this menu item is used,
that the correct form is displayed!

Here's the function (air code). Note that the item in the commandbars
reference is the number of the control from the left. You won't need
any references set up for the items in the function, as everything runs
fom vba just fine:

Function fToggleEditMyForm(f as Access.Form)

'This function toggles the allowedit property of the form
'passed in the argument, f.
'
'f is the form being toggled.

'I realize the following could be achieve in less lines
'using the NOT operator, but I like this sort of thing as
'I find it easier to figure out WTF I was doing when
'I look at the code later

'Assume menu control is number 3 (arbitrary - Your
'mileage may vary)

if commandbars("mnuCustomMenuName").controls(3).State = true then

'Control is currently ticked/depressed (state property), so
'turn it OFF and turn allowedits OFF.

commandbars("mnuCustomMenuName").controls(3).State = False

f.Allowedits = false

else

'Control is currently not ticked/depressed (state property), so
'turn it ON and turn allowedits ON.

commandbars("mnuCustomMenuName").controls(3).State = True

f.Allowedits = True

end if

Exit_Proc:

Exit function

Err_Proc:

'This is pretty fool proof, so I don't include any error handling

End Function
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: jbbs | last post by:
I have a question regarding on the button and label. i don't know why when the mouse cursor points on the button, i see the button is flirking. is there anyway to make it not behave like that?...
4
by: Neil Coleclough | last post by:
I am constructing a database to process product returns for my Company. I have a number of toggle buttons to identify the stage to which each return has been processed. For example, clicking the...
1
by: Keith Harris | last post by:
Hi, I have a Repeater control which is bound to a dataset. In the footer of the repeater control, I have a Button whose visibility I want to vary according to the sum of a column being > 0. ...
1
by: kimmie | last post by:
I am using buttons on a toolbar and I want to use the buttons as toggles. When I click the button the first time I want my picture box to display by setting the picture box to visible. But I need...
2
by: Mel | last post by:
Hi, is there any way I can implement toolstrip toggle button simular to the MS Word alignment button? if one toggle button already pressed down, if user click on the "pushed down button", the...
3
by: Killer42 | last post by:
Hi all. I have a frame with some toggle buttons in it. All is working fine, except that the user can't tell which option is selected to begin with. How do I set one of the toggle buttons to the...
1
by: Michel Vanderbeke | last post by:
Hello, Is it possible to use a Toolbar Button as a toggle, so that one click shows a form and a second click closes it again? MAny thanks and greetings, Michel
1
by: Jeffrey Christiansen | last post by:
I wanted to add a toggle button to a VB2005 form to be used for a simple Windows Application (i.e. compiled to a "*.exe"), so I added the ActiveX Microsoft Forms Object toggle button, however I...
0
by: ARC | last post by:
Hello all, In access 2007, it appears you cannot put a toggle button underneath a menu id and have it show a Pressed / Not Pressed status. If you make the toggleButton ID as part of the main...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.