473,383 Members | 1,958 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,383 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 3334
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.